/    Sign up×
Community /Pin to ProfileBookmark

"document.write" command and printing true HTML

I am wondering if there is a way to see rendered/executed code that uses the “document.write” Javascript command to print .html.

In this example we insert this code when the page is served:

=========================================

<SCRIPT LANGUAGE=”JavaScript”>
<!–
clkZone = “obituary”;
ord=Math.random()*10000000000000000;
if (location.search.match(“Page=Directions”)) {
clkZone = “funeral”;
}
document.write(‘<table width=”100%” cellpadding=”0″ cellspacing=”0″ border=”0″><tr><td height=”5″><img src=”/shared-local/images/1pix_trans.gif” width=”1″ height=”5″ border=”0″></td></tr></table>’);
document.write(‘<SCR’ + ‘IPT LANGUAGE=”JavaScript” SRC=”http://www.test.com‘ + clkZone + ‘;pg=’ + clkZone + ‘” ></SCR’ + ‘IPT>’);
//–>
</SCRIPT>

=========================================

When I have clients view source on the actual webpage I would like them to see the entire SCR reference with the “clkzone” variable populated in the url.

So basically, is there a way to have the browser show the executed .html that is write by the “document.write” command. Is there a way to grab just the .html and print it below the .js?

Any ideas are helpful!

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@crh3675Jul 22.2004 — Not unless your variable is populated by a server or your page is created through script entirely. In other words, say you have

<i>
</i>&lt;script&gt;

var varValue="Text for window";

var xwin=window.open('','myWin');
xwin.document.open();
xwin.document.write("&lt;html&gt;&lt;body&gt;"+varValue+"&lt;/body&gt;&lt;/html&gt;");
xwin.document.close();

&lt;/script&gt;


viewing the source of your popup will give you full source
Copy linkTweet thisAlerts:
@CharlesJul 22.2004 — [font=monospace]<script type="text/javascript">

<!--

String.prototype.asHTML = function () {return ['<pre>', this.replace(/x3C/g, '&lt;').replace(/x3E/g, '&gt;'), '</pre>'].join('')}

ord = Math.random()*10000000000000000;

clkZone = /Page=Directions/.test(location.search) ? 'funeral' : 'obituary';

textA = '<table width="100%" cellpadding="0" cellspacing="0" border="0"><tr><td height="5"><img src="/shared-local/images/1pix_trans.gif" width="1" height="5" border="0"></td></tr></table>';

textB = '<SCR' + 'IPT LANGUAGE="JavaScript" SRC="http://www.test.com' + clkZone + ';pg=' + clkZone + '" ></SCR' + 'IPT>';

document.write(textA.asHTML(), textB.asHTML());

// -->

</script>[/font]
×

Success!

Help @tribeman3819 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...