/    Sign up×
Community /Pin to ProfileBookmark

Hi…

The referenced ‘HTML Preview’ script which is located on the main site, doesn’t work (at least not after copying, pasting and following the simple directions).

Does anyone know a script that will permit my visitors to enter HTML into a text box, then click ‘Preview’ for the results to show in a new window?

Thank you!

to post a comment
JavaScript

11 Comments(s)

Copy linkTweet thisAlerts:
@CharlesNov 26.2005 — <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<meta name="Content-Style-Type" content="text/css">
<title>Example</title>
</head>
<body>
<div><textarea></textarea></div>
<div><button onclick="win = window.open ('', 'child', 'height=400,width=300'); win.document.write (document.getElementsByTagName ('TEXTAREA')[0].value); win.document.close(); win.focus()">Write</button></div>
</body>
</html>
Copy linkTweet thisAlerts:
@syn0psisauthorNov 27.2005 — Thank you Charles!
Copy linkTweet thisAlerts:
@syn0psisauthorNov 27.2005 — Charles.....the script you provided works. However, in the resulting window, this is displayed:

[B][I]NaN minutes and NaN seconds [/I] [/B]

Nothing else shows. But, if you view the source code....the HTML is present??

Does that make sense?

Thanks!
Copy linkTweet thisAlerts:
@konithomimoNov 27.2005 — You would have to supply the content that you are trying to display in the popup. As long as you are using the first textarea.
Copy linkTweet thisAlerts:
@konithomimoNov 27.2005 — Also, NaN stands for "Not - a - Number". The value taken from a textarea/textbox is seen as a string, so if you want it to be evaluated as a number then use parseInt or parseFloat to get it as a number.
Copy linkTweet thisAlerts:
@CharlesNov 27.2005 — Is this, perhapse, what yuou are up to:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Content-Script-Type" content="text/javascript">
<meta name="Content-Style-Type" content="text/css">
<title>Example</title>
</head>
<body>
<div><textarea></textarea></div>
<div><button onclick="win = window.open ('', 'child', 'height=400,width=300'); win.document.write ([b]eval ([/b]document.getElementsByTagName ('TEXTAREA')[0].value[b])[/b]); win.document.close(); win.focus()">Write</button></div>
</body>
</html>
Copy linkTweet thisAlerts:
@syn0psisauthorNov 27.2005 — Hi....

It's [u]close[/u]. Here is exactly what I'm doing. Perhaps I didn't explain it thoroughly enough to provide you with the information you need to access my issues.

I have developed a form, which I run locally. The form is simply for my benefit. I use it to expedite the building of complex tables, by filling in a few fields which, in turn, generate the needed width/height/number of cells, etc.

Then, I hit generate, grab my code and place it on whichever clients pages requires the changes. My current method dictates that I save the generated code, then view it in a browser so as to make certain my results meet my intentions.

I got to thinking that if I could add a 'Preview HTML Window' below my textbox, where the code is generated.....I could save a lot of time.

My entire form works...and works well. It's adding a preview button and child window that I am fighting with.

Thanks!!!
Copy linkTweet thisAlerts:
@konithomimoNov 27.2005 — Try this:
<i>
</i>&lt;html&gt;
&lt;head&gt;
&lt;script type="text/javascript"&gt;
function displayHTML(form) {
var inf = form.htmlArea.value;
document.getElementById('div1').innerHTML=inf;
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form&gt;
&lt;textarea name="htmlArea" cols=45 rows=6&gt;
&lt;/textarea&gt;
&lt;br&gt;
&lt;input type="button" value="Preview " onclick="displayHTML(this.form)"&gt;
&lt;/form&gt;
&lt;div id="div1" &gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;


Or if you want it to open in a new window:
<i>
</i>&lt;html&gt;
&lt;head&gt;
&lt;script type="text/javascript"&gt;
function displayHTML(form) {
var inf = form.htmlArea.value;
win = window.open(", ", 'popup', 'toolbar = no, status = no');
win.document.write("" + inf + "");
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;form&gt;
&lt;textarea name="htmlArea" cols=45 rows=6&gt;
&lt;/textarea&gt;
&lt;br&gt;
&lt;input type="button" value="Preview " onclick="displayHTML(this.form)"&gt;
&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@syn0psisauthorNov 28.2005 — Thanks konithomimo....but the top example, when I clicked 'preview' displayed a 'clone' of the text box only.

The second example poped up an error box that read 'Cannot Find'. I did include some simple HTML in the textbox to test it when the error occurred.

This has become a challenge to figure out now!! But I promise...when I do, I'll post the solution here!

Thank you for your help!!
Copy linkTweet thisAlerts:
@konithomimoNov 28.2005 — You might have to put in full html if you want it in a new window.
Copy linkTweet thisAlerts:
@sdukesMar 08.2006 — I got an error with your code too.

HTML:

<html>

<head>

<title></title>

</head>

<body>This is my one line web page

</body>

</html>

Error:

Can not find 'file:///C:Test/,'
×

Success!

Help @syn0psis 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 5.18,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

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

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...