[英]What is wrong in my script?
What is wrong in my small script when I press the jquery button.当我按下 jquery 按钮时,我的小脚本有什么问题。 It does not open the url.
它不会打开网址。 I'm missing a comma some where.
我在某处遗漏了一个逗号。
<script type='text/javascript'>
$('#include-from-outside').load('https://www.*******.com');
</script>
<a href="#" class="easyui-linkbutton" onclick="addTab('jquery','<div id='include-from-outside'></div>')">jquery</a>
您需要将 ID 的'
更改为\\"
:-
<a href="#" class="easyui-linkbutton" onclick="addTab('jquery','<div id=\"include-from-outside\"></div>')">jquery</a>
I see a few potential issues with this.. the onclick="addTab(...);我看到了一些潜在的问题。 onclick="addTab(...);
In your script you want to create a function that it is calling.在您的脚本中,您要创建一个它正在调用的函数。 I pulled up the jqueryeasyui page, and looked into the function you were calling.. Try adding this to your page.
我打开了 jqueryeasyui 页面,并查看了您正在调用的函数。尝试将其添加到您的页面中。
<script>
function addTab(title, url){
if ($('#tt').tabs('exists', title)){
$('#tt').tabs('select', title);
} else {
var content = '<iframe scrolling="auto" frameborder="0" src="'+url+'" style="width:100%;height:100%;"></iframe>';
$('#tt').tabs('add',{
title:title,
content:content,
closable:true
});
}
}
</script>
In general.. an onclick="addTab()" <-- will call the addTab function in your script.一般来说.. onclick="addTab()" <-- 将在您的脚本中调用 addTab 函数。 So when you create the function above, this will handle the variables you are passing into it.
所以当你创建上面的函数时,这将处理你传递给它的变量。
Since you are passing a static html
as a parameter, you don't need it as a parameter to javascript
function.由于您将静态
html
作为参数传递,因此您不需要它作为javascript
函数的参数。 Also, you can embed the click event in your href
.此外,您可以将 click 事件嵌入到您的
href
。
<a href="javascript:addTab('jquery');" class="easyui-linkbutton">jquery</a>
<script>
function addTab(language)
{
var html = "<div id='include-from-outside'></div>";
alert(language);
}
</script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.