Forum Moderators: open

Message Too Old, No Replies

New Window

         

cmatcme

8:34 am on Apr 17, 2005 (gmt 0)

10+ Year Member



In the body of my webpage I have placed the following code which is used to open a new window:

<script>

function opennew {

newopened = window.open("","opened,"scrollbar=yes","toolbar=no","directories=no","menubar=no","width=450","height=250");
newopened.focus();
newopened.document.open();
newopened.document.write("<% = trim(request("q")) %>");
newopened.close();

}

</script>

<form>
<input type="button" onClick="opennew();" value="Open">
</form>

The text opened in the window is based on a variable. The variable is what the user entered in a form - that part works fine. When I click on the link I get an OBJECT EXPECTED error.

Any ideas

cmatcme

PS :: This goes on a long list of failing javascript functions so it's probably to do with that!

Rambo Tribble

1:52 pm on Apr 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You need to clean up your syntax:


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>Untitled</title>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function opennew() {
newopened = window.open("","opened","scrollbars=yes,width=450,height=250");
newopened.focus();
newopened.document.open();
newopened.document.write('<% = trim(request("q")) %>');
newopened.document.close();
}
</script>
</head>
<body>
<form action="">
<p>
<input type="button" onClick="opennew();" value="Open" />
</p>
</form>
</body>
</html>

(I edited out the property=no assignments, as they are assumed, though for security reasons not all browsers will respect status=no, any more.)

cmatcme

2:53 pm on Apr 17, 2005 (gmt 0)

10+ Year Member



Thanks Rambo Tribble :) Would anyone know how to make the window appear a certain distance from the side of the screen and the top (like x any y co-ordinates)?

cmatcme

Rambo Tribble

4:32 pm on Apr 17, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



newopened = window.open("","opened","scrollbars=yes,width=450,height=250,left=200,top=150");

cmatcme

5:07 pm on Apr 17, 2005 (gmt 0)

10+ Year Member



Thanks once again.

cmatcme