...

View Full Version : Enforcing Validation check within iframe



brendon99
08-11-2005, 05:40 AM
Hi,

I have a HTML Page with a couple of buttons across the top, which determine what source appears in an iframe beneath. In one of the pages within the iframe, I'm validating input - when an error occurs, I simply wish the user to be prevented from leaving this page until the error is fixed. However, if I click one of the buttons across the top in the main html page, then I get an error message, and the source of the iframe is changed regardless.

Is there a way to enforce the iframe source to remain, even if I trigger an event from outside of it?

many thanks,

Brendon

vwphillips
08-11-2005, 03:41 PM
simple example


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

<html>

<head>
<title></title>
<script language="JavaScript" type="text/javascript">
<!--

var Lk=true;

function CngSRC(url){
if (!Lk){
document.getElementById('MyiFrame').src='http://www.js-examples.com';
}
}

//-->
</script>
</head>

<body>
<input type="button" name="" value="Change URL" onclick="CngSRC();" >
<iframe src="mm1.htm" id="MyiFrame" name="MyiFrame" frameborder="1"></iframe>

</body>

</html>



mm1.htm



<html>
<head>

</head>

<body >

<input type="button" name="" value="Lock SRC" onclick="parent.Lk=true; ">
<input type="button" name="" value="Un Lock SRC" onclick="parent.Lk=false; ">
<br>

</body>
</html>


set Lk true or false in your validation



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum