Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Embed code from linked external page

    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:

    Code:
    <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.

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,928
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    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.

  • #3
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Philip M View Post
    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"?


  •  

    Posting Permissions

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