...

View Full Version : Content from a JavaScript var to display on a separate page



srhs
07-14-2004, 05:07 PM
I currently have a vertical scroll with lots of content in it. The script reads from an external js file and scrolls the HTML that I have in the var.

Example:

var content='<b>My content is here</b>';

That is the very first thing in the file and then the rest of the script is listed. The external js file is named scrolltext.js.

I would like to have a separate page set up where either a form field or just a section on the page can read the content of the scroller and display it all at once. The purpose for this would be so the site users can see all of the content without having to wait for it to scroll through. I update the content a lot and this solution would be easier, if possible, than copying and pasting it to another page every time I update it.

Can someone help me? Thanks a lot.

jamescover
07-15-2004, 02:53 AM
<script language="javascript" type="text/javascript" src="external.js">
</script>

<script>
<!--

function getVar(){

document.content = (data);
var mWin = window.open("","","");
mWin.document.open();
mWin.document.writeln("<html>");
mWin.document.writeln("<head>");
mWin.document.writeln("<title>Page Source<\/title>");
mWin.document.writeln("<\/head>");
mWin.document.writeln("<body topmargin=\"10\" marginheight=\"10\" leftmargin=\"10\" marginwidth=\"10\">");
mWin.document.writeln("<center>");
mWin.document.writeln("<table border=\"0\" width=\"750\" valign=\"top\">");
mWin.document.writeln("<tr>");
mWin.document.writeln('<td width=\"750\" valign=\"top\"><div align=\"justify\">'+ document.content +'<\/div><\/td><\/tr><\/table>');
mWin.document.writeln("<\/center>");
mWin.document.writeln("<\/body>");
mWin.document.writeln("<\/html>");
mWin.document.close();
}

//-->
</script>




<form name="mForm">
<input type="button" name="mbut" value="getVar" onClick="javascript:getVar();" />
</form>

Contents of external.js:

var data = ("This is where my content goes...");


http://www.ekigroup.com/javascript/getVar.html

-james

srhs
07-16-2004, 03:23 PM
Thank you very much for your help. I just threw the script you gave me into the existing js file and everything seems to be working fine! Thanks again.

jamescover
07-16-2004, 03:28 PM
:thumbsup:



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum