Displaying content input in browser address bar?
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.
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>");
See the data: URI scheme.
精彩评论