/    Sign up×
Community /Pin to ProfileBookmark

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.

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@Gozzy82Feb 25.2010 — 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
Copy linkTweet thisAlerts:
@01denauthorFeb 26.2010 — 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.
Copy linkTweet thisAlerts:
@Gozzy82Feb 26.2010 — 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/10/loading-external-content-with-ajax-using-jquery-and-yql/ (Proxying with PHP)
Copy linkTweet thisAlerts:
@01denauthorFeb 26.2010 — thanks again I will have a look now and hopefully it will help
Copy linkTweet thisAlerts:
@01denauthorFeb 26.2010 — 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.
Copy linkTweet thisAlerts:
@01denauthorFeb 26.2010 — 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?
Copy linkTweet thisAlerts:
@Gozzy82Feb 26.2010 — 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
Copy linkTweet thisAlerts:
@01denauthorFeb 26.2010 — cool thats allot easier then having to use regex thank you
×

Success!

Help @01den spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...