Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: Copying Values from a DhtmlWindow to other dhtmlwindow...

  1. #1
    Join Date
    Apr 2008
    Posts
    27
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Exclamation Copying Values from a DhtmlWindow to other dhtmlwindow...

    1) Script Title:
    dhtmlwindow

    2) Script URL (on DD):
    http://www.dynamicdrive.com/dynamici...ndow/index.htm

    3) Describe problem:
    I want to copy values from one dhtmlwindow to other...
    is it possible ?

    hi there again..
    i am trying to copy values like this:

    Code:
    parent.window2.document.getElementById('newdiv').innerHTML=document.getElementById('div1').innerHTML
    I am getting that newdiv have zero value or there is no object...

    The same trying to get values with document.all()

    :-( what i am doing wrong...

    Thanx in advance...

  2. #2
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    It definitely should be possible, though how do to it depends on how your windows are opened- via IFRAME, Ajax, inline DIV etc? Also, just to clarify, I gather you wish to, inside WindowB, create a link that when clicked on copies the contents of a DIV on the parent Window to WindowA right?

  3. #3
    Join Date
    Apr 2008
    Posts
    27
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    not only at parent...

    but it could be and at the parent...too...

    by the way i am using iframe..

    can u help me?

  4. #4
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    I assume the pages contained in the IFRAME are all within the same domain as the parent window's page? JavaScript doesn't allow cross domain access.

  5. #5
    Join Date
    Apr 2008
    Posts
    27
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    yes they are open in my localhost into the same page! :-)

  6. #6
    Join Date
    Apr 2008
    Posts
    27
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by ddadmin View Post
    I assume the pages contained in the IFRAME are all within the same domain as the parent window's page? JavaScript doesn't allow cross domain access.
    IS AT the same domain - and same parent window's page!

  7. #7
    Join Date
    Apr 2008
    Posts
    27
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    gouxou gouxou - i am sorry.. can anyone help at that ?

  8. #8
    Join Date
    Aug 2004
    Posts
    10,143
    Thanks
    3
    Thanked 1,008 Times in 993 Posts
    Blog Entries
    16

    Default

    Speaking in general, you can access the page contents embedded via IFRAME and shown inside the DHTML Window in the following way. Say you have the following to open a DHTML window:

    Code:
    var mywinz=dhtmlwindow.open("pagebox", "iframe", "test.htm", "My Web Page", "width=590px,height=350px,resize=1,scrolling=1,center=1", "recal")

    And inside test.htm, you have the below form:

    Code:
    <form>
    <input type="text" id="myname" value="George" />
    </form>
    Now, on your parent page, you can alert the value of the form contained inside test.htm with the code:

    Code:
    <a href="#" onClick="alert(window.frames['_iframe-pagebox'].document.getElementById('myname').value); return false">Get value</a>
    The key is the code:

    Code:
    window.frames['_iframe-pagebox']
    Which is how you access from the parent page the document contained inside the DHTML Window via IFRAME. Change pagebox to match the ID of the DHTML window div when you called dhtmlwindow.open() earlier.

    With this info you should also be able to access the contents of one DHTML window from another. From within WindowB, just remember to first navigate back to the parent window before constructing the rest of your code to access WinA, something like:

    Code:
    parent.frames['_iframe-pagebox'].document.getElementById('myname').value

  9. The Following User Says Thank You to ddadmin For This Useful Post:

    cyberd (04-23-2008)

  10. #9
    Join Date
    Apr 2008
    Posts
    27
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    You are my man! :-)

    Yo!~ !! !!! !! :-) THANK u very Much!

    in Greek: se efharisto poli !

    working very good !

  11. #10
    Join Date
    Apr 2008
    Posts
    27
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default

    and because we are in the same subject...

    how i will print from other window (iframe) one other...

    for example :

    i am in windowb and and i want to print windowa contents...

    like this:

    parent.frames['_iframe-windowa].document.window.print();

    ... ?

    thanx again...

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •