outputting html through string variable

T

Tom

I am trying to output an string that is made up of HTML tags using the
document.write. The string is taken from the URL. However, my output
is given as text rather than being read by the browser as HTML. Any
thoughts? Here is my code.

<html>
<head>
<title>final2</title>
</head>
<body bgcolor="#FFFFCC">
<FORM NAME="tom">
<INPUT TYPE="hidden" NAME="check">
</FORM>

<SCRIPT LANGUAGE="javascript">

var locate = window.location
document.tom.check.value = locate

var text = document.tom.check.value

function delineate2(str)
{
point = str.lastIndexOf("=");
return(str.substring(point+1,str.length));
}
var a = delineate2(text)
var newString = a.replace(/%3C/g,"&#60");
var newString2 = newString.replace(/%3E/g,"&#62");
var newString3 = newString2.replace(/%2F/g,"&#47");
var newString4 = newString3.replace(/%22/g,"");

document.write('newString4');


</SCRIPT>


</body>
</html>

OUTPUT IS SIMPLY THE TAGS!
 
M

McKirahan

Tom said:
I am trying to output an string that is made up of HTML tags using the
document.write. The string is taken from the URL. However, my output
is given as text rather than being read by the browser as HTML. Any
thoughts? Here is my code.

<html>
<head>
<title>final2</title>
</head>
<body bgcolor="#FFFFCC">
<FORM NAME="tom">
<INPUT TYPE="hidden" NAME="check">
</FORM>

<SCRIPT LANGUAGE="javascript">

var locate = window.location
document.tom.check.value = locate

var text = document.tom.check.value

function delineate2(str)
{
point = str.lastIndexOf("=");
return(str.substring(point+1,str.length));
}
var a = delineate2(text)
var newString = a.replace(/%3C/g,"&#60");
var newString2 = newString.replace(/%3E/g,"&#62");
var newString3 = newString2.replace(/%2F/g,"&#47");
var newString4 = newString3.replace(/%22/g,"");

document.write('newString4');


</SCRIPT>


</body>
</html>

OUTPUT IS SIMPLY THE TAGS!

Try changing
document.write('newString4');
to
document.write(newString4);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top