开发者

Show values in another document controls

开发者 https://www.devze.com 2022-12-15 01:02 出处:网络
I want to show some JavaScript array values in another document Input Boxes. Previously, I was using:

I want to show some JavaScript array values in another document Input Boxes. Previously, I was using:

document.getElementByID('....').value = ....

Now I want to know how to replace the 'document' with another page.

Edited:

My page opens two tables side-by-side. First table contains controls and the second contains and IFrame and inside that frame is enclosed a data-grid. When the user clicks on a row in the开发者_Go百科 grid, results are fetched and I want to show in the controls of table1.


You can use the context of the jQuery method ie the $(..., context) to do this.

$("#someElement", top.document).val($("#someOtherElement").val());

This sets the value of #someElement in the main document, to the value of #someOtherElement in the iframe. Code is supposed to be run from within the iframe, because that's where your button handling is most likely to be.

To go the other way you could use:

$("#someElement", $("#iframeId").contents()).val($("#someOtherElement").val());


In JavaScript the only other documents you can reference are iframes inside the page itself that have the same domain. You could simply do, var iframeDocument = document.getElementById("iframeId").contentWindow.document

0

精彩评论

暂无评论...
验证码 换一张
取 消