PDA

View Full Version : killing code execution


jollywoz
11-01-2002, 12:47 PM
hello,
is there any way of completely stopping a pages rendering (even html) using javascript? i'm testing for a condition and if it is true then i use doc.write to send a message but dont want the rest of the html to show up...any ideas?

thx in advance

RadarBob
11-01-2002, 01:36 PM
Shooting from the hip here...

First you'd either have to do this server-side or, client-side you'd have a whole mess of "document.write" statements.

The third alternative is on the client to write it using THE document object model(DOM) - but IMHO this is one of those "these are professionals.. don't try this at home!"

So, whether you choose one of the first two options, the code structure is the same I think. There may be variations, but the general approach should be the same.

You'd have your web page built inside a giant IF statement. Might look like this, server-side. I'm using ASP notation. WARNING. This is not tested, working code.:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Now you see me, now you don't</title>

</head>
<body>
<!-- rendering the stuff you want to render -->

<form name="RenderMan" method="post">

<%
if (request.RenderMan("someCondition").value == 'yes') {
%>
<!-- here's the page part you build if it's true -->
<%
}else{
%>
<!-- here's the page part you build if it's not true
the way I've written this, I THINK this part will execute when
the page is FIRST rendered/initialized; because the field being
tested doesn't yet exist. -->
<%
} // end if
%>

<!-- here's the rest of the page that will always show up -->

<!-- need some kind of mechanism that sets the condition one
way or the other. -->
Can you hear me now?
<br>
<input type="radio" name="someCondition" value="no" checked> No
<br>
<input type="radio" name="someCondition" value="yes"> Yes


<input type="submit" value=" Rebuild the Page ">
</form>

</body>
</html>

jollywoz
11-01-2002, 02:00 PM
nice one.

gonna have to try it client side, got the rope attached and i'm going in. if i'm not back in 20 mins call a web designer :thumbsup:

beetle
11-01-2002, 02:22 PM
I'd like to know what this condition it, and it's purpose. I'm sure you really don't want to just STOP the HTML output. Maybe display an alert or redirect the user.

Tell me what you are doing more specifically and I'll let you know what I think your options are....

Garadon
11-01-2002, 04:31 PM
on way is to take the html out and put in another file then load that according to ur if statemennt

Location.href="htmlcode.html";