dcsimg
www.webdeveloper.com
Results 1 to 9 of 9

Thread: Javascript Question

  1. #1
    Join Date
    Feb 2010
    Posts
    6

    Javascript Question

    Hi all,

    heres my senerio I am trying to load an external webpage i.e.: a free directories submit page into an iframe and wish to autofill the for found in that page with user supplied data when the page has completed loading but can not figure out how to do this.

    I can get the page to load completely and call the javascript function but cannot access the form controls in the loaded page.

    can someone help me please.

    thankyou.

  2. #2
    Join Date
    Feb 2010
    Location
    Amsterdam
    Posts
    174
    you cant access any elements on a page from a different domain because of security reasons, if you want to access that page you can use a serverside proxy which loads the external page

  3. #3
    Join Date
    Feb 2010
    Posts
    6

    thanks for relying Gozzy82

    thanks for your reply Gozzy82 i had a feeling about that but was not to sure.

    sorry for being stupid but when you say that I can use a proxy what do you mean?

    I could i guess use php to load it but I don't really know what a proxy is sorry.

  4. #4
    Join Date
    Feb 2010
    Location
    Amsterdam
    Posts
    174
    a proxy is like a "in between" this page deals with xmlhttp but its the same for an iframe http://www.wait-till-i.com/2010/01/1...query-and-yql/ (Proxying with PHP)

  5. #5
    Join Date
    Feb 2010
    Posts
    6
    thanks again I will have a look now and hopefully it will help

  6. #6
    Join Date
    Feb 2010
    Posts
    6
    hi again

    I have written a curl class for loading the page into a variable and am passing it to a js function see below:

    function fillFrame(page){
    var ifrm=document.getElementById('myiframe');

    var doc = ifrm.document;
    if(ifrm.contentDocument){
    doc = ifrm.contentDocument; // For NS6
    }
    else if(ifrm.contentWindow){
    doc = ifrm.contentWindow.document; // For IE5.5 and IE6
    }
    // Put the content in the iframe
    doc.open();
    doc.writeln(page);
    doc.close();
    }

    'myiframe' is the id of the iframe on my page but when i load the page it does not show in the iframe but outside the frame can you tell what i am doing wrong?

    thankws again for your help i appreciate it.

  7. #7
    Join Date
    Feb 2010
    Posts
    6
    I have just figured it out thank you it is now loading it iframe but now I guess i will have to set the absolute paths to all images and links using php or can you think of an easier way?

  8. #8
    Join Date
    Feb 2010
    Location
    Amsterdam
    Posts
    174
    hi, glad you got it working, for all the links and images you can use a base tag: http://www.w3schools.com/TAGS/tag_base.asp

  9. #9
    Join Date
    Feb 2010
    Posts
    6
    cool thats allot easier then having to use regex thank you

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles