How to setup norton seal for angularjs site?

本秂侑毒 提交于 2019-12-21 20:25:56

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/40744864/how-to-setup-norton-seal-for-angularjs-site

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!