tags:

views:

60

answers:

2

I don't know if I'll be able to describe this correctly, so please bear with me!

Is it possible to get the browser to display html from the address bar? ie. there would be no actual html page it would load, but it would instead display whatever was inside the address bar? Might this be something for javascript or is that not possible?

Hope that makes sense! I'll clarify if need be. Many thanks for any help, much appreciated.


Edited to try and clarify the OP's question

I want to use the URL to generate the page, for example (Using Jonathan Sampson's answer):

javascript:document.write("<b>HelloWorld</b>");

...but I want it for a whole page, ie. include all the html in the HelloWorld part.

+3  A: 

Really difficult to understand what is being asked here. If you input the following into your address bar, you will output HTML onto the document:

javascript:document.write("<b>HelloWorld</b>");

This type of stuff is only really helpful when programming bookmarklets though. If you decide to do something like this, be sure to escape the inner quotes. For example, below I have unescaped double-quotes around my style rules.

javascript:document.write("<b style="text-decoration:underline">foo</b>");

The appropriate way to write this would be:

javascript:document.write("<b style=\"text-decoration:underline\">foo</b>");

Or

javascript:document.write("<b style='text-decoration:underline'>foo</b>");
Jonathan Sampson
Thank you. What I want is what you have done in the first part, but I want it for a whole page, ie. include all the html in the HelloWorld part. Is that possible? Thank you!
James Wanchai
Yes, you can do `javascript:document.write("<html><head><title>test</title></head><body><h1>HelloWorld</h1></body>");` from the browser address bar.
anshul
Doesn't seem to work though for a big page? I'll try again though.
James Wanchai
Your snippet works, but when I try with a full web page, that does work when rendered normally, nothing happens at all?
James Wanchai
@James: Make sure to escape inner quotes.
Jonathan Sampson
Bingo! Thank you Jonathan. Much appreciated!
James Wanchai
A: 

See the data: URI scheme.

David Dorward