faqts : Computers : Programming : Languages : JavaScript

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

2 of 7 people (29%) answered Yes
Recently 2 of 7 people (29%) answered Yes

Entry

Is it possible to change javascript to html?

Apr 8th, 2008 18:36
ha mo, Dave Clark, xi06,


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     I would need an explanation of what you mean by that.  You can 
certainly use JavaScript to change the HTML -- that is what is called 
DHTML.  You can also display JavaScript code as if it were HTML text 
merely by placing the JavaScript code within quotes.  However, I'm not 
sure if that is what you're asking.  An example of this is if you use 
IE to visit a web page and then enter the following into the browser's 
addressbar:
javascript:var myWin=window.open
("","myWin","width=800,height=600,scrollbars,resizable,menubar");var 
myStr=document.documentElement.outerHTML;myStr=myStr.replace(/
\r\n/g,"##").replace(/&/g,"&").replace(/\</g,"<").replace(/
\>/g,">").replace(/##/g,"<br>");myWin.document.open
();myWin.document.write(myStr);myWin.document.close();
    That will attempt to create a popup window in which all of the 
HTML and JavaScript in that web page is displayed as normal text.  If 
you have a popup blocker, though, then that might not work.   ;-)
Take care,
Dave Clark
www.DaveClarkConsulting.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
http://www.businessian.com
http://www.computerstan.com
http://www.financestan.com
http://www.healthstan.com
http://www.internetstan.com
http://www.moneyenews.com
http://www.technologystan.com
http://www.zobab.com
http://www.healthinhealth.com