...

View Full Version : Embed code from linked external page



jwelch127
01-17-2009, 06:32 PM
I want to give a code snippet to partnering websites, so that the script on their page draws from a page on my server. I think "quote of the day" type widgets use this. Here is an example of the code I would give them, where "mysamplesite.com/sample.php" would be a page on my server:



<script type="text/javascript" language="JavaScript" src="http://www.mysamplesite.com/sample.php?version=31&amp;jscript=1&newtarget=1"></script>


I copied this code from a site and it works for them, but when I switch the url to a php page (containing only text wrapped in a div) on my site, it doesn't work. I realize this might also be a php question, but I didn't want to cross-post. Does it have something to do with the "jscript=1" variable being passed?

Sorry if this is vague. I'm new to programming so I don't even know the terminology of this technique. Thanks for any help.

Philip M
01-17-2009, 06:47 PM
For security reasons JavaScript cannot access anything beyond the domain of the current page. This is known as the "same origin policy" and prevents a document or script loaded from one origin from getting or setting properties of a document from a different origin.

jwelch127
01-17-2009, 07:54 PM
For security reasons JavaScript cannot access anything beyond the domain of the current page. This is known as the "same origin policy" and prevents a document or script loaded from one origin from getting or setting properties of a document from a different origin.
Thanks, but I don't think we're on the same page. I looked up the Same Origin Policy (Wikipedia), and a critical part says: "(it)...prevents access to most methods and properties across pages on different sites."

The keyword is "most." Obviously there is some way to do what I've asked, since I have been on the receiving end of this situation. For instance, the quotations on my IGoogle page are drawn from http://www.quotationspage.com. How does that bypass the "Same Origin Policy"?



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum