在popup.body.html中点击img标签 [英] onclick of img tag inside popup.body.html
本文介绍了在popup.body.html中点击img标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 popup.body.innerhtml内的
。 img
标签内需要 onclick
事件
我尝试使用以下代码,但点击
事件未使用以下代码触发。
我无法调用 JavaScript
功能或服务器端功能。
你能帮忙吗。
谢谢。
代码:
oPopup.document.body.innerHTML ='< a href = # > < td > < img ID = im1 alt = im1 height = 350 runat = server onclick = image1() src = 来源/图片/'+ s [ 1] +' / > 跨度> <温泉n class =code-keyword>< / td > < td > < img ID = im2 alt = im2 height = 350px onClick = src = 来源/图片/'+ s [2] + ' / > < / td > < span class =code-keyword>< td > < img alt = im3 ID = im3 < span class =code-attribute> height = 350px onClick = src = 来源/图片/'+ s [3] +' / > < / td > < / a > ';
在该图片中 onclick
我无法调用客户端或服务器端的任何功能。
有什么建议吗?
解决方案
这是一个解决方案
< html >
< < span class =code-leadattribute> head >
< title > < / title >
< < span class =code-leadattribute> script type = text / javascript >
<! -
var oPopup = window .createPopup()
function goPop(oHeight){
var oPopupBody = oPopup。 document .body;
var lefter = event.offsetY + 100 ;
var topper = event.offsetX + 100 ;
oPopupBody.innerHTML = stylediv.innerHTML;
oPopup.show(topper,lefter, 400 ,oHeight, document .body);
document .body.onmouseup = closePopup;
}
function closePopup(){
oPopup.hide();
}
function fillPopup(titler,texter,linker){
oTitle.innerText = titler;
oText.innerText = texter;
}
// - >
< / script >
< script type = text / javascript >
<! -
function Button1_onclick(){
goPop( 300 );
}
// - >
< / script >
< / head >
< body >
< 输入 id = Button1 type = 按钮 value = 按钮 onclick = 返回Button1_onclick() / >
< div id = stylediv 样式 = display:none >
< script type = text / javascript >
<! -
function FollowLink_onclick(){
window .parent.open( www.google.com, _ blank )
}
// - >
< / script < span class =code-keyword>>
< div style = 位置:绝对;顶部:0;左:0;边框:1px solid#6699cc;宽度:400;高度:300像素; z-index:3; >
< div id = oTitle style = position:relative;宽度:100%;背景:#FFFFFF;高度:32PX;字体重量:粗体;填充:5像素; font-size:10pt; > 提示标题< / div >
< div id = oText style = 填充:5px >
< img id = FollowLink < span class =code-attribute> alt = 单击 src = http://s.codeproject.com/App_Themes/Std/Img/logo250x135.gif style = width :48;高度:48; onclick = window.parent.open('http://www.google.com','_ blank') / >
< / div >
< / div >
< / div >
< / body >
< / html >
< html >
< head >
< title > < / title >
< script 类型 = text / javascript >
<! -
var oPopup = window.createPopup()
函数goPop(o高度){
var oPopupBody = oPopup.document.body;
var lefter = event.offsetY + 100;
var topper = event.offsetX + 100;
oPopupBody.innerHTML = stylediv.innerHTML;
oPopup.show(topper,lefter,400,oHeight,document.body);
document.body.onmouseup = closePopup;
}
函数closePopup(){
oPopup.hide();
}
函数fillPopup(titler,texter,linker){
oTitle.innerText = titler;
oText.innerText = texter;
}
// - >
< / script >
< script type = text / javascript >
<! -
function Button1_onclick(){
goPop(300);
}
// - >
< / script >
< / head >
< body >
< 输入 id = Button1 type = button < span class =code-attribute> value = 按钮 onclick = 返回Button1_onclick() / >
< div id = stylediv style = display:none >
< script type = text / javasc ript >
<! -
function FollowLink_onclick(){
window.parent.open(www.google.com,_ blank)
}
// - >
< / script >
< ; div style < span class =code-keyword> = position:absolute;顶部:0;左:0;边框:1px solid#6699cc;宽度:400;高度:300像素; z-index:3; >
< div id = oTitle style = position:relative;宽度:100%;背景:#FFFFFF;高度:32PX;字体重量:粗体;填充:5像素; font-size:10pt; > 提示标题< / div >
< div id = oText style = 填充:5px >
< img id = FollowLink < span class =code-attribute> alt = 点击我 src = http://s.codeproject.com/App_Themes/Std/Img/logo250x135.gif style = width:48;高度:48; onclick = window.parent.open('http://www.google.com','_ blank') / >
< / div >
< / div >
< / div >
< / body >
< / html >
你应该去JQuery实时功能。当你从javascript或服务器端代码注入到UI的动态代码时。
Hi, I need onclick
event inside img
tag inside popup.body.innerhtml
.
I tried with the following code, but click
event is not firing with the below code.
I couldnot call either JavaScript
function or server side function.
Can you please help.
Thank you.
code:
oPopup.document.body.innerHTML = '<a href="#"><td> <img ID="im1" alt="im1" height="350" runat="server" onclick="image1()" src="Source/Images/' + s[1] + '" /></td><td><img ID="im2" alt="im2" height="350px" onClick="" src="Source/Images/' + s[2] + '" /></td><td><img alt="im3" ID="im3"height="350px" onClick="" src="Source/Images/' + s[3] + '" /></td></a>';
In that image onclick
I couldnot call any function either client side or server side.
Any suggestions?
解决方案
Here is a solution
<html> <head> <title></title> <script type="text/javascript"> <!-- var oPopup = window.createPopup() function goPop(oHeight) { var oPopupBody = oPopup.document.body; var lefter = event.offsetY + 100; var topper = event.offsetX + 100; oPopupBody.innerHTML = stylediv.innerHTML; oPopup.show(topper, lefter, 400, oHeight, document.body); document.body.onmouseup = closePopup; } function closePopup() { oPopup.hide(); } function fillPopup(titler, texter, linker) { oTitle.innerText = titler; oText.innerText = texter; } // --> </script> <script type="text/javascript"> <!-- function Button1_onclick() { goPop(300); } // --> </script> </head> <body> <input id="Button1" type="button" value="button" onclick="return Button1_onclick()" /> <div id="stylediv" style="display:none"> <script type="text/javascript"> <!-- function FollowLink_onclick() { window.parent.open("www.google.com", "_blank") } // --> </script> <div style="position:absolute; top:0; left:0; border:1px solid #6699cc; width:400; height:300px; z-index:3;"> <div id="oTitle" style="position:relative; width:100%; background:#ffffff; height:32px; font-weight:bold; padding:5px; font-size:10pt;">Title of tip</div> <div id="oText" style="padding:5px"> <img id="FollowLink" alt="Click Me" src="http://s.codeproject.com/App_Themes/Std/Img/logo250x135.gif" style="width: 48; height: 48;" onclick="window.parent.open('http://www.google.com', '_blank')" /> </div> </div> </div> </body> </html>
<html> <head> <title></title> <script type="text/javascript"> <!-- var oPopup = window.createPopup() function goPop(oHeight) { var oPopupBody = oPopup.document.body; var lefter = event.offsetY + 100; var topper = event.offsetX + 100; oPopupBody.innerHTML = stylediv.innerHTML; oPopup.show(topper, lefter, 400, oHeight, document.body); document.body.onmouseup = closePopup; } function closePopup() { oPopup.hide(); } function fillPopup(titler, texter, linker) { oTitle.innerText = titler; oText.innerText = texter; } // --> </script> <script type="text/javascript"> <!-- function Button1_onclick() { goPop(300); } // --> </script> </head> <body> <input id="Button1" type="button" value="button" onclick="return Button1_onclick()" /> <div id="stylediv" style="display:none"> <script type="text/javascript"> <!-- function FollowLink_onclick() { window.parent.open("www.google.com", "_blank") } // --> </script> <div style="position:absolute; top:0; left:0; border:1px solid #6699cc; width:400; height:300px; z-index:3;"> <div id="oTitle" style="position:relative; width:100%; background:#ffffff; height:32px; font-weight:bold; padding:5px; font-size:10pt;">Title of tip</div> <div id="oText" style="padding:5px"> <img id="FollowLink" alt="Click Me" src="http://s.codeproject.com/App_Themes/Std/Img/logo250x135.gif" style="width: 48; height: 48;" onclick="window.parent.open('http://www.google.com', '_blank')" /> </div> </div> </div> </body> </html>
You should go for JQuery live function.When ever you are having dynamic code injected from javascript or server side code to UI.
这篇关于在popup.body.html中点击img标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文