jquery - JavaScript Event Handler in ASP.NET -


i have following iframe control (intended facebook button):

<iframe id="likebutton"     src="http://www.facebook.com/plugins/like.php?href="      scrolling="no"      frameborder="0"              style="border:none; overflow:hidden;      width:450px; height:80px;"     onprerender="setuplink()" </iframe> 

i have javascript function defined above follows:

<script type="text/javascript">   function setuplink()   {     var iframe = $("#likebutton");     var newsrc = iframe.attr("src");     newsrc += encodeuricomponent(location.href) + lblkey.text;      iframe.attr("src", newsrc);   }; </script> 

lblkey label on asp.net page references specific section of page. however, far can determine, function doesn’t called (if put alert() @ start brings nothing up). i’m new javascript, looking around @ articles on web indicate should update src property on iframe.

edit:

i have tried following:

<script type="text/javascript" > $(function() {     var iframe = $("#likebutton");     var newsrc = iframe.attr("src");     newsrc += encodeuricomponent(location.href) + '<%= lblkey.text %>';      iframe.attr("src", newsrc); }); </script> 

which doesn't work, neither does:

<script type="text/javascript" > $(function() {     alert('hello'); }); </script> 

have considered using onload event , passing reference iframe?

<script type="text/javascript"> function change_source(iframe) {   if (iframe.src.indexof('facebook') < 0)   {     iframe.src = 'http://www.facebook.com/plugins/like.php?href=<%= lblkey.text %>';   } } </script> 

html this...

<iframe id="likebutton"     src="about:blank"      scrolling="no"      frameborder="0"              style="border:none; overflow:hidden;      width:450px; height:80px;"     onload="change_source(this);" </iframe> 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -