如何为angularjs网站设置Norton Seal? [英] How to setup norton seal for angularjs site?

查看:81
本文介绍了如何为angularjs网站设置Norton Seal?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为我的angularjs网站设置Norton Seal.每当Norton脚本加载它时,都会在我的控制台中显示警告,例如,

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."

我知道该脚本是异步加载的,这意味着它已与文档解析状态分离.实际上,JS引擎根本无法知道应该在页面中执行document.write的位置.我现在正在使用 postcribe .但是我想知道,是否有比使用 postscribe

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.

推荐答案

我今天遇到了同样的问题,在搜索了互联网并与一些同事讨论之后,我们提出了以下解决方案:

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:

首先,您需要使用 postcribe : https://github.com/krux/postscribe

它将替换所有 document.write 调用,以便您不再从浏览器中收到此错误.

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 ..');

然后,您只需要在站点上的某个地方放置 div id ="seal" ,它将被实际的印章图像替换.

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

但是,如果此 div 位于您的角度应用程序内部,则需要在角度应用程序内部调用 postscribe .

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

我通过创建一个指令(包含div)来做到这一点,在该指令中添加了一个 post 链接函数.在发布函数中,我只是如上所述调用postscribe.如果您需要这种方法,我可以写一个片段.

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.

这篇关于如何为angularjs网站设置Norton Seal?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆