如何让这个javascript代码在Mac上运行

How to get this javascript code working on Mac

本文关键字:Mac 运行 代码 javascript      更新时间:2023-09-26

如何让这段代码在Safari(Mac OS)上运行

JavaScript

document.getElementById("name").src = "../index.html";
document.getElementById("name").herf = "http://google.com/index.html";

.html

<iframe id="name" src="../imghp" width="30%" height="103" name="iamiframe">
            <p>Your Brower doesn't support iframe so: <a href="http://google.com/imghp">click</a></p>
</iframe>

你到底想干什么?

因为,如果您想将谷歌页面嵌入您的 iframe 中,并且如果不支持 iframe ,则期望此错误链接

<!DOCTYPE>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
<iframe id="name" src="" width="30%" height="103" name="iamiframe">
    <p>Your Brower doesn't support iframe so: <a href="http://google.com/imghp">click</a></p>
</iframe>

<script>
    // or you can directly put in on the src iframe attribute
    document.getElementById("name").src = 'http://www.test.com';
</script>
</body>
</html>

这段代码似乎有效,对你来说?

PS :如果你想直接 google.com iframe,我们将处理这个错误:拒绝在帧中显示"https://www.google.ca/?gfe_rd=cr&ei=JaOAVIe9GefE8genlYCoAQ&gws_rd=ssl",因为它将"X帧选项"设置为"SAMEORIGIN"

希望这有帮助,

C