Javascript asp.net div/iframe作为目标
我有一个名为Javascript asp.net div/iframe作为目标,javascript,html,iframe,Javascript,Html,Iframe,我有一个名为mainContent的div,如果我单击要清除mainContent的链接,请在div中添加一个iframe,并从iframe中的链接打开页面 怎么做呢? 我想需要一些JS? <a href="javascript:SetContent();">Some link</a> <script> function SetContent() { document.getElementById('mainContent').i
mainContent
的div,如果我单击要清除mainContent
的链接,请在div中添加一个iframe
,并从iframe
中的链接打开页面
怎么做呢?
我想需要一些JS?
<a href="javascript:SetContent();">Some link</a>
<script>
function SetContent()
{
document.getElementById('mainContent').innerHTML =
"<iframe width=" + screen.width + "px height=" + screen.height +
"px src='http://www.SomeUrl.com'></iframe>";
}
</script>
函数SetContent()
{
document.getElementById('mainContent')。innerHTML=
"";
}
你喜欢什么
函数addiframe(){
document.getElementById(“maincontent”).innerHTML='';
}
自闭症
试试这个片段。您需要包括jquery库才能使用它
function appendContent(){
$('#mainContent').html('');
$('#mainContent').html('<iframe name="myiframe" width=620 height=380 src="http://stackoverflow.com" frameborder="1"></iframe>');
}
函数appendContent(){
$('#mainContent').html('');
$('#mainContent').html('');
}
完美。就是这样。有没有办法用当前分辨率的宽度/高度创建iframe?是的,您可以使用screen.width
和screen.height
访问分辨率最后一个问题,假设我想将文本框的值作为参数添加到SetContent()
如何调用文本框。
中的文本值?
知道为什么iframe中的内容比在新页面中打开时小吗?可以将其设置为与平常相同的大小吗?为什么不使用jquery的强大功能而不是传统的javascript呢。
function appendContent(){
$('#mainContent').html('');
$('#mainContent').html('<iframe name="myiframe" width=620 height=380 src="http://stackoverflow.com" frameborder="1"></iframe>');
}