我正在尝试获取input class=input type=text以添加到与页面地址无关的链接。 生成的link+text-entry将显示在iframe中。
我尝试了以下(我在这里找到):
function GET_IT() { var link = document.getElementById("LINKHERE"); var hrefOrig = link.href; var dd = document.getElementById("TEXT_ID"); dd.onchange = function(){ link.href = hrefOrig + dd.value; } } window.attachEvent("load", init, false);有:
<form target="IFRAME" method="get"> <input class"input" type="text" size="25" id="TEXT_ID"> <input type="submit" value "Go" onClick="javascript: function('GET_IT');"> </form>它所做的只是循环回到所有输入的页面,在iFrame中......
I'm trying to obtain an input class=input type=text to add to a link not related to the page's address. The resulting link+text-entry will be displayed in an iframe.
I tried the following (which I found on here):
function GET_IT() { var link = document.getElementById("LINKHERE"); var hrefOrig = link.href; var dd = document.getElementById("TEXT_ID"); dd.onchange = function(){ link.href = hrefOrig + dd.value; } } window.attachEvent("load", init, false);with:
<form target="IFRAME" method="get"> <input class"input" type="text" size="25" id="TEXT_ID"> <input type="submit" value "Go" onClick="javascript: function('GET_IT');"> </form>All it did was loop back the page that everything was entered into, in the iFrame...
最满意答案
您的JavaScript函数应如下所示:
function GET_IT() { var link = document.getElementById("LINKHERE"); var hrefOrig = link.href; var dd = document.getElementById("TEXT_ID"); //Change the source of the iFrame with the new HREF... document.getElementById('IFRAME ID').src = hrefOrig + dd.value; }这是我能给你的最好的答案,而不会看到更多的代码。 查看此链接以获取可能对您有所帮助的更完整示例:
使用Javascript更改iframe src
提琴手示例:
http://jsfiddle.net/VkSRY/1/
Your JavaScript function should look something like this:
function GET_IT() { var link = document.getElementById("LINKHERE"); var hrefOrig = link.href; var dd = document.getElementById("TEXT_ID"); //Change the source of the iFrame with the new HREF... document.getElementById('IFRAME ID').src = hrefOrig + dd.value; }This is the best answer I can give you without seeing more code. Check out this link for a more complete example that might help you:
Changing iframe src with Javascript
Fiddler Example:
http://jsfiddle.net/VkSRY/1/
更多推荐
发布评论