本文介绍了使用javascript在锚标记中分配URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hi,
My problem is on the page loads i want to assign the url in the anchor tag like below. But it not working at all. I tried in both a way with and without runat server.
window.onload = function () {
document.getElementById('placeholder').href = 'drawPicture.aspx?code=MIL-2653-22CT&width = 550';
}
<a id="placeholder" rel="zoom-width:600px; zoom-height:600px" class="MagicZoom">
But it work's fine when i put the aboove URL directly like below
<a id="placeholder" rel="zoom-width:600px; zoom-height:600px" href="drawPicture.aspx?code=MIL-2653-22CT&width = 550" runat="server" class="MagicZoom">
But i want to be done by like " document.getElementById('placeholder').href = 'drawPicture.aspx?code=MIL-2653-22CT&width = 550';"
Please help !!
推荐答案
<script type="text/javascript">
然后在页面中添加你的anchoe标签
Then add your anchoe tag in page
<a id="placeholder" rel="zoom-width:600px; zoom-height:600px" runat="server" >click</a>
这篇关于使用javascript在锚标记中分配URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!