HTML脚本标记和非JS内容 - Firefox [英] the HTML script tag and non-JS content - Firefox
问题描述
< script type =这个代码会在Chrome和IE中请求文件, text / my-custom-mime-typesrc =test.ashx>
< / script>
是否有一些说明,说浏览器应该只处理JavaScript相关的MIME类型?
我知道IE可能支持这个,因为有vbscript的历史。
一旦你有这样的内容下载你如何能够访问它?
JavaScript / jQuery /?有一些方法得到这个。
更新
所以有2部分问题。听起来像第一部分 - 浏览器将下载它将下载的内容,我猜根据目前的答案,你可以做的不多。
示例:
< script type =text / xml-script>
< ; page xmlns =http://schemas.microsoft.com/xml-script/2005>
< components>
< application load =page_load/>
< / components>
< / page>
< / script>
< / pre>
微软声明MSAjax技术的片段。你可以从外部文件中拉入吗?注意:我不想在这里使用MSAjax,但是它是一个用于脚本标记的自定义类型的好例子。 第二部分 - 如果内容下载,你能访问文本吗?例如,可以说它的JavaScript - 你可以在文本框中显示它吗? (没有显式的Ajax调用)?
是否有一些规范说浏览器应该只处理JavaScript相关的MIME类型?
请参阅 type attribute :
这个属性给出关于链接目标地址处可用内容的内容类型的建议性提示。它允许用户代理选择使用回退机制,而不是获取内容,如果他们被告知将获得他们不支持的内容类型的内容。
如果您想要获取脚本中使用的任意内容,请使用XMLHttpRequest。
It appears this code will request the file in Chrome and IE but not in Firefox.
<script type="text/my-custom-mime-type" src="test.ashx">
</script>
Is there a some spec that says browsers should only process JavaScript related mime-types? I know IE probably supports this because of the history with vbscript.
Once you have "content" like this downloaded how can you get access to it? Does JavaScript/jQuery/? have some way of getting at this.
UPDATE So there is 2 parts to question. Sounds like for the first part - the browser will download what it will download and I guess there isn't much you can do about that based off the answers so far.
Example:
<script type="text/xml-script">
<page xmlns="http://schemas.microsoft.com/xml-script/2005">
<components>
<application load="page_load" />
</components>
</page>
</script>
</pre>
this is a snippet from Microsoft's declarative MSAjax tech. Could you pull this in from an external file. Note: I'm not trying to use MSAjax here, but its a good example of a custom type being used for a script tag.
Part 2 - can you get access to the text if the "content" does download? For example, lets say its JavaScript - could you display it in a textbox? (without an explicit Ajax call)?
Is there a some spec that says browsers should only process JavaScript related mime-types?
See the type attribute:
This attribute gives an advisory hint as to the content type of the content available at the link target address. It allows user agents to opt to use a fallback mechanism rather than fetch the content if they are advised that they will get content in a content type they do not support.
If you want to fetch arbitrary content for use in a script, use XMLHttpRequest.
这篇关于HTML脚本标记和非JS内容 - Firefox的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!