JavaScript Import file problem

Discussion in 'Javascript' started by Joseph Scoccimaro, Nov 21, 2005.

  1. I am using greasemonkey to create a script that allows one to analyze a
    web page. Currently I am trying to import the javascript from an
    external file to add to the DOM of a web page. It is giving me this
    error: Security Error: Content at http://www.google.com/ may not load or
    link to file:///home/majin/8903/greasemonkeyscript/metaanalysis.js. Is
    there a way to get around this? Here is the code I am using:

    metaAnalysis: function(scriptSource) {

    var theHead = document.getElementsByTagName('head')[0];
    var metaAnalysisScript = document.createElement('script');
    metaAnalysisScript.type = 'text/javascript';
    metaAnalysisScript.src = scriptSource;
    theHead.appendChild(metaAnalysisScript);

    } //end metaAnalysis()

    metaAnalysis('file:///home/majin/8903/greasemonkeyscript/metaanalysis.js');
    //this is the calling function.


    Joseph Scoccimaro
     
    Joseph Scoccimaro, Nov 21, 2005
    #1
    1. Advertising

  2. Joseph Scoccimaro

    Randy Webb Guest

    Joseph Scoccimaro said the following on 11/21/2005 11:31 AM:
    > I am using greasemonkey to create a script that allows one to analyze a
    > web page. Currently I am trying to import the javascript from an
    > external file to add to the DOM of a web page. It is giving me this
    > error: Security Error: Content at http://www.google.com/ may not load or
    > link to file:///home/majin/8903/greasemonkeyscript/metaanalysis.js. Is
    > there a way to get around this?


    The only way is to stop trying to script cross-domain. It appears you
    are trying to append the script file into a google.com page from your
    hard drive. That is a serious serious security issue that you can't get
    around in a normal default security environment.

    If you want to access the data on www.google.com for analysis, you would
    do better to have a local HTML file that uses an HTTPRequestObject to
    retrieve the contents of google.com and then display it in your own page.

    --
    Randy
    comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
    Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
     
    Randy Webb, Nov 21, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Paul Opal
    Replies:
    12
    Views:
    973
    Paul Opal
    Oct 11, 2004
  2. JPractitioner
    Replies:
    13
    Views:
    20,189
    Roedy Green
    Feb 24, 2006
  3. Vitali Gontsharuk
    Replies:
    2
    Views:
    578
    Vitali Gontsharuk
    Aug 25, 2005
  4. Stefan Seefeld
    Replies:
    3
    Views:
    975
  5. per9000
    Replies:
    7
    Views:
    421
    Magnus Lycka
    Feb 27, 2006
Loading...

Share This Page