使用javascript在锚标记中分配URL [英] Assigning the URL in the anchor tag.using javascript

查看:84
本文介绍了使用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 !!

推荐答案

试试这个: -



try this:-

<script type="text/javascript">


(document).ready(function(){

document.getElementById(<% = placeholder.ClientID %> )。href =' LogOut.aspx;

});
< / script >
(document).ready(function() { document.getElementById("<%=placeholder.ClientID %>").href = 'LogOut.aspx'; }); </script>





然后在页面中添加你的anchoe标签



Then add your anchoe tag in page

<a  id="placeholder" rel="zoom-width:600px; zoom-height:600px"  runat="server" >click</a>


这篇关于使用javascript在锚标记中分配URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆