您好我试图在我的博客中插入一些可点击的文字,其中有一个弹出窗口


 < script type =“text / javascript”src =“https ://app.getresponse.com/view_webform_v2.js U = BvFE6&安培; webforms_id = 2645901" >< /脚本>
 代码>


 会出现。我该怎么做呢?感谢

答案 0 :(得分:0)
您必须在页面中添加脚本:
$('.behaviourTr').on('click', function(e) {
if (!$(e.target).is('span')) {
// The tr was clicked, but the span wasn't
}
});
答案 1 :(得分:0)
如果要求不允许使用jquery,那么你也可以使用javascript在运行时使用下面的代码附加脚本:
<!doctype HTML>
<html>
<head>
<title>Append script on runtime</title>
<style type="text/css">
#text-link {
color: blue;
cursor: pointer;
}
</style>
</head>
<body>
<div id="blog-content">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam pretium sodales turpis.
<span id="text-link">fermentum lacinia</span> ligula. Aliquam erat volutpat.
</div>
<script type="text/javascript">
window.onload = function() {
document.getElementById("text-link").addEventListener("click", addScript);
function addScript(){
var script = document.createElement('script');
script.src = 'https://app.getresponse.com/view_webform_v2.js?u=BvFE6&webforms_id=2645901';
document.head.appendChild(script);
// if wants to support IE < 9 then instead of document.head use
// document.getElementsByTagName('head')[0]
}
}
</script>
</body>
</html>
如果代码已存在,您可以进一步增强代码以仅附加一次。
答案 2 :(得分:-1)
<p class='appendScriptTag'> click me </p>
<script>
$('.appendScriptTag').on('click',function(){
var s = document.createElement("script");
s.type = "text/javascript";
s.src = "https://app.getresponse.com/view_webform_v2.js?u=BvFE6&webforms_id=2645901";
$("head").append(s);
})
</script>
答案 3 :(得分:-1)
我们可以使用jQuery在运行时使用下面的代码附加脚本:
$("<script>", {
src: "https://app.getresponse.com/view_webform_v2.js?u=BvFE6&webforms_id=2645901",
type: "text/javascript"
}).appendTo("body");
我们可以在点击元素时使用相同的脚本。请参阅以下代码以获取工作示例。
<!doctype HTML>
<html>
<head>
<title>Append script on runtime</title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<style type="text/css">
#text-link {
color: blue;
cursor: pointer;
}
</style>
</head>
<body>
<div id="blog-content">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam pretium sodales turpis.
<span id="text-link">fermentum lacinia</span> ligula. Aliquam erat volutpat.
</div>
<script type="text/javascript">
$(document).ready(function() {
$("#text-link").on("click", function() {
$("<script>", {
src: "https://app.getresponse.com/view_webform_v2.js?u=BvFE6&webforms_id=2645901",
type: "text/javascript"
}).appendTo("body");
});
});
</script>
</body>
</html>