[英]JavaScript window.open onclick ('url')
I just figured out that I needed this link to be inside a data
tag, because the data
uses " ", and I can't include both. 我只是想知道我需要将此链接放在
data
标签中,因为data
使用“”,并且我不能同时包含两者。
Is this possible to do with document.getElementById("id")
? 这可能与
document.getElementById("id")
吗?
Or do I need another script for this? 还是为此需要其他脚本? As you can tell I'm not the best with JavaScripts yet.
如您所知,使用JavaScript并不是最好的选择。 Hope to learn a thing or two.
希望学习一两件事。
<a href="chat" onclick="return popitup('chat')">Pop</a>
<script>
function popitup(url) {
newwindow=window.open(url,'name','toolbar=no, location=no, status=no, menubar=no, scrollbars=no, resizable=no,height=600,width=330');
if (window.focus) {newwindow.focus()}
return false;
}
</script>
<a href="#" class="emotes show-pop btn btn-default top" data-title="Settings" data-content="<a href="chat" onclick="return popitup('chat')">Pop</a>"><img src="img/settings.png"></a>
你需要躲避"
的属性值
<a href="#" class="emotes show-pop btn btn-default top" data-title="Settings" data-content="<a href="chat" onclick="return popitup('chat')">Pop</a>"><img src="img/settings.png"></a>
After referring this stackoverflow post, I tried to reproduce your code as below. 在引用了这个stackoverflow帖子之后,我尝试如下重现您的代码。 Thing you missed is that you need to escape '<','>' and '"'
您错过的是您需要转义'<','>'和'“'
<a href="chat" onclick="return popitup('chat')">Pop</a>
<script>
function popitup(url) {
newwindow=window.open(url,'name','toolbar=no, location=no, status=no, menubar=no, scrollbars=no, resizable=no,height=600,width=330');
if (window.focus) {newwindow.focus()}
return false;
}
</script>
<a href="#" class="emotes show-pop btn btn-default top" data-title="Settings" data-content='<a href="chat" onclick="return popitup("chat")">Pop</a>'>
<img src="img/settings.png">
</a>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.