3

I am trying to setup norton seal for my angularjs site. every-time when norton script loads its says a warning in my console like,

"Failed to execute 'write' on 'Document': It isn't possible to write into a document from an asynchronously-loaded external script unless it is explicitly opened."

I understood that The script is being loaded asynchronously, which means it's detached from the document parsing state. There is quite literally NO WAY for the JS engine to know WHERE the document.write should be executed in the page. I am using postcribe now.But i want to know ,if there is a better approach than using postscribe

Is there any way to make this run.Thanks for any help.

Nikhil Mohanan
  • 1,260
  • 1
  • 12
  • 23
  • Possible duplicate of [How to defer loading of a Norton Secure Site Seal?](http://stackoverflow.com/questions/14872978/how-to-defer-loading-of-a-norton-secure-site-seal) – Daniel B Nov 22 '16 at 15:12
  • There are multiple answers on SO that answer this specific question. The issue is with the `document.write()` as you stated, but you can easily delay that by defering the script load. Just Google the error message and you'll find multiple answers. – Daniel B Nov 22 '16 at 15:24
  • Just look at my comment, I posted a link there to a question with an answer for you. Your question is about the same as multiple other questions that have the same answer. The only answer in this thread requires a third party library while thats not necessary. I'm not intending to be rude, I just don't think this has to be asked when it's been answered before. – Daniel B Nov 23 '16 at 08:50
  • your comment and linked answer ,not going to help me.My question and requirement is different.But unfortunately you marked it as duplicate for first look, and may be its going to impact others perception . – Nikhil Mohanan Nov 23 '16 at 09:02

1 Answers1

5

I had the same problem today and after searching through the interwebs and discussing with some of my colleagues we came up with the following solution:

First of all you need to use postcribe: https://github.com/krux/postscribe

It will replace all document.write calls so that you don't get this error from the browser anymore.

e.g. in my case I do the following:

.postscribe('#seal', '... put the norton seal script tag here ..');

Then you only need to have a div id="seal" somewhere on your site and it will be replaced by the actual seal image.

However, if this divis inside your angular application you need to call postscribe inside the angular application.

I did this by creating a directive (which holds the div) where I added a post link function. In the post function I simply call postscribe as above. I can write a snippet if you need this approach.

FlorianTopf
  • 938
  • 6
  • 10
  • Thanks for the answer.I am using `postcribe` now.But i thought may be somebody can suggest a better approach without using `postscribe`.i upvote this. – Nikhil Mohanan Nov 23 '16 at 04:28
  • How did you actually import and use postscribe in your angular app? – Anthony Dec 13 '17 at 20:44
  • I found this plunker on how to implement: http://embed.plnkr.co/FHSVKDL2rv8TAQyTeqE2/ I added the postscribe function to ngAfterViewInit – Anthony Dec 14 '17 at 14:47