0

I'm reading out the header of a webpage through:

var srccat=$("*").contents().filter(function(){return this.nodeType == 8;}).get(0).nodeValue;

Then I'm doing some splits and all, which is all working fine. (I have to read out the header, because a variable is being 'displayed' as text and there is no other way to get to this info...)

However, the page isn't rendering correctly (because it depends on this) and is throwing an error in the console:

"SCRIPT5: Access is denied."

According to the link to "SCRIPT5" (https://msdn.microsoft.com/query/dev12.query?appId=Dev12IDEF1&l=EN-US&k=k(VS.WebClient.Help.SCRIPT5)), it states: "A script tried to access data from a source other than the host of the current page. The Same Origin Policy followed by Internet Explorer and other browsers allows scripts to access data only from sources with the same scheme, host, and port of the URL of the current page." I assume this has to do with Backbone. I'm not THAT familiar with it, but I understand that it works as a page within a page, so that in my case it's reading information from the 'parent' page.. and I guess this is not allowed in IE...

The error ONLY occurs in IE(11), not in Firefox or Chrome. Is there a workaround for this?

Malachi
  • 977
  • 6
  • 16
  • 31
  • 2
    Reconsider your use of `$("*")`. What exactly are you trying to do? Get all the comments? – Scott Marcus Mar 03 '17 at 22:06
  • try like `src="//msdn.microsoft.com/query/dev12.query?appId=Dev12IDEF1&l=EN-US&k=k(VS.WebClient.Help.SCRIPT5"` once. or try to do this:- [how to disable same origin policy](http://www.thegeekstuff.com/2016/09/disable-same-origin-policy/?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+TheGeekStuff+(The+Geek+Stuff)) – Alive to die - Anant Mar 03 '17 at 22:08
  • to find out which IE Emulation Mode (aka documentMode) your test/production environment is using Press f12, then select the Emulation tab, eg. IE7 - User setting - display Intranet sites in Compatibility View.... to find out which IE security zone your test/production environment maps to (viz is it in the Intranet zone and so using IE7 emulation) use the File>Properties menu from IE – Rob Parsons Mar 04 '17 at 06:25
  • @ScottMarcus Yes, I want the comments! – Malachi Mar 04 '17 at 14:54
  • @RobParsons Well, no... it's using IE's standard settings. And I don't want to change that, because I'm not the only one having the issues... – Malachi Mar 04 '17 at 14:55
  • @Anant I won't change IE's standard settings.. I need to do something with my code instead that goes around the issue... – Malachi Mar 04 '17 at 14:56
  • Please post a snippet of your markup showing which conditional comments you are using.... IE11 Edge mode ignores conditional comments. Also please have a look at the Emulation tab of the dev tool and post back with what you find. – Rob Parsons Mar 04 '17 at 20:12
  • @RobParsons The comment in the header is like this: I tried to make it run as IE10 and IE9, but it still gave the same issue.... Either way.. in my code I want to get something like "sct" for example and get it's value. – Malachi Mar 06 '17 at 16:35

1 Answers1

0

I had the same problem with CORS within IE only. I had to use a work around of jQuery's CORS support.

// enables cross origin ressource sharing with IE9
$.support.cors = true;

Is it safe to use $.support.cors = true; in jQuery?

Place this before any other ajax requests are made but after loading jQuery (obviously).

Community
  • 1
  • 1
Emile Bergeron
  • 17,074
  • 5
  • 83
  • 129