0

如何获取以下提示并使用用户在提示中键入的内容并将其转换为 iFrame URL,如下所示:

<iframe src="http://www.weather.com" sandbox="" seamless="" width="100%" height="200 </iframe>


<html>
<head>
<script>
function disp_prompt()
 {
var sitename=prompt("Please enter your Website:","www.anywebsite.com")
document.getElementById("msg").innerHTML="Your Site: " + sitename
}
</script>
</head>
<body>

<input type="button" onclick="disp_prompt()" value="Click to enter in Website URL">
<br><br>

<div id="msg"></div>

</body>
</html>
4

2 回答 2

0
<html>
<head>
<body>

<iframe id="iframeID" src="http://www.weather.com" sandbox="" seamless="" width="100%" height="200"></iframe>
    <form name="FormInput" action="" method="get" id="input" onsubmit="document.getElementById('iframeID').src=document.FormInput.site.value;">
 Website URL: 
<input type="text" name="site"/>
<br/>
<br/>
<input type="submit" value="Submit"/>
<br/>
</form>


<div id="msg"></div>

</body>
</html>
于 2013-02-16T22:57:45.980 回答
0

在 Youtube、Vimeo 上工作

希望能帮助到你:

单击此处运行脚本

function createIFrame(url, width, height){

switch(url.substring(7,12)){
    case "www.y":
        return url.replace(/(?:http:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=)?(.+)/g, '<iframe width="'+width+'" height="'+height+'" src="http://www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>');       
        break;
    case "youtu":
         return url.replace(/(?:http:\/\/)?(?:www\.)?(?:youtube\.com|youtu\.be)\/(?:watch\?v=)?(.+)/g, '<iframe width="'+width+'" height="'+height+'" src="http://www.youtube.com/embed/$1" frameborder="0" allowfullscreen></iframe>');       
        break;
    case "vimeo":
        return url.replace(/(?:http:\/\/)?(?:www\.)?(?:vimeo\.com)\/(?:\/\?)?(.+)/g, '<iframe width="'+width+'" height="'+height+'" src="http://player.vimeo.com/video/$1" frameborder="0" allowfullscreen></iframe>');
        break;
}

}

于 2013-08-13T19:35:17.383 回答