使用脚本标记跨站点脚本,更改脚本标记的src,我们可以使用id作为脚本标记 [英] cross site scripting using script tag ,change src of a script tag, can we use id for script tag

查看:125
本文介绍了使用脚本标记跨站点脚本,更改脚本标记的src,我们可以使用id作为脚本标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<body>
<!-- some html code -->

<script src='some.js'></script>

<!-- some html code -->

</body>

脚本some.js加载表单。
,当我按下该表单的更新时,我不提交表单而是我形成一个查询字符串,并希望将其发送为
some.js?key = value

The script some.js loads a form. when i press update in that form i do not submit the form instead i form a query string and want to send it as some.js?key=value

现在我需要更改脚本标签的src。

Now i need to change the src of the script tag.

如果我们更改src它会再次请求新内容吗?
我们可以使用ID作为脚本标记,如果是这样,它将被所有浏览器支持吗?

If we change the src will it work by again requesting a new content? Can we use ID for script tag and if so will it be supported by all browsers?

当收到新内容时,我将清除显示的旧内容通过这个脚本。
我认为最好有一个div并将所有内容放在div中。
i我在我的htaccess中将script.phs重写为script.php只是向用户显示它只是一个javascript访问或者对我来说没问题,如果我给.php。

when the new content is received i will clear the old content displayed by this script. i think it is better to have a div and put all the contents inside that div. i am rewriting script.js to script.php in my htaccess just show the users that it is just a javascript access or no problem for me if i give a .php.

以上是基本要求。

我们需要的只是使用一个脚本标签,它将从另一个站点获取内容并在此处更新。

What we need is just to use a script tag which will fetch content from another site and should update here.

您可以以标准方式提供建议,包括更新x网站的内容。

you can give suggestions to use this in a standard way which will included updating the content from the x site.

所以这就是人们所说的跨站点脚本,按需javascript,请添加更多术语,如果有的话我会更新自己。

so this is what people tell as cross site scripting, on demand javascript and please add more terminologies if any so that i will update myself.

任何类型的响应都会有用。

any kind of response will do good.

推荐答案

根据W3C(http://www.w3.org/TR/REC-html40/interact/scripts。 html#h-18.2.1)'script'标签不支持任何标准属性(包括'id'),但它适用于大多数浏览器。我建议删除标签并添加新标签,而不是替换'script'标签'src'属性 - 这样更可靠。我强烈建议您阅读JSONP和跨源资源共享(http://www.w3.org/TR/cors/) - 这些标准可以帮助您实现您想要的目标。

According to W3C (http://www.w3.org/TR/REC-html40/interact/scripts.html#h-18.2.1) 'script' tag doesn't support any standard attributes (which includes 'id'), however it will work in most browsers. Instead of replacing 'script' tag 'src' attribute I would suggest removing the tag and adding new one - that’s more reliable. I would strongly suggest reading about JSONP and Cross-Origin Resource Sharing (http://www.w3.org/TR/cors/) - those are standards which should help you achieve what you want.

这篇关于使用脚本标记跨站点脚本,更改脚本标记的src,我们可以使用id作为脚本标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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