views:

49

answers:

3

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"&gt; <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)?

+4  A: 

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.

David Dorward
+1 for actually answering the question. Now I'm curious what the OP is trying to do...
jtbandes
jtbandes, what is an OP?
tyndall
Original Poster. Traditional term for the person who posted the first message to a thread on a mailing list, Usenet group or other forum.
David Dorward
Learn something new every day
tyndall
+1  A: 
mplungjan
doesn't matter what content-type I send. I'm not trying to send text/javascript
tyndall
A: 

Are you setting the content type. Guessing .NET here so posting basic idea:

public class Handler : IHttpHandler {
    public void ProcessRequest (HttpContext context) {
         context.Response.ContentType = "text/javascript";
         context.Response.Write("alert('hello world');");
    }
}
epascarello
sorry was just using the ashx as an example. could be any file extension. this is just how I generate non-page content in .NET. But the script may even be a static file. Just wondering if its possible.
tyndall