Javascript Event Handler In Asp.net June 07, 2023 Post a Comment I have the following iframe control (intended to be a facebook like button): Solution 1: asp.net events (like prerender) don't apply anywhere else (like javascript)assuming you are using jquery, I would wrap that in a $(), which is a shorthand for "Execute the following as soon as the page has loaded enough to start manipulating it". Also, asp.net controls have a different api then dom elements, so if you want to use that api you need to wrap it in a scriptlet tag<scripttype="text/javascript"> $(function () { var iframe = $("#likeButton"); var newSrc = iframe.attr("src"); newSrc += encodeURIComponent(location.href) + "<%= lblKey.Text %>"; iframe.attr("src", newSrc); }); </script>CopySolution 2: Have you considered using the onload event and passing a reference to the iframe?<scripttype="text/javascript">functionchange_source(iframe) { if (iframe.src.indexOf('facebook') < 0) { iframe.src = 'http://www.facebook.com/plugins/like.php?href=<%= lblKey.Text %>'; } } </script>CopyHTML something like 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> Copy Share Post a Comment for "Javascript Event Handler In Asp.net"
Post a Comment for "Javascript Event Handler In Asp.net"