...

View Full Version : Open window in new window but with no menu etc at the top



ziguana_man
05-23-2005, 12:04 PM
Hello, I have the below code in a webpage to open a link in a new window but I get an error on line 9 Char 2 - 'Null' is null or not an object. Anyone any ideas? the code works on another page!

<HTML><HEAD><TITLE>VE</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<script type="text/javascript">
<!--
function openBrWindow(theURL,winName,features)
{
window.open(theURL,winName,features);
}
-->
</script>

<SCRIPT src="../VE%20-%20Home_files/library.js"
type=text/javascript></SCRIPT>

<SCRIPT src="../VE%20-%20Home_files/main.js"
type=text/javascript></SCRIPT>
<LINK href="../Victoria%20Electricity%20-%20Home_files/style.css" type=text/css
rel=stylesheet><LINK href="../icon.gif" type=image/gif rel=icon>
<META content="MSHTML 6.00.2900.2604" name=GENERATOR><style type="text/css">
<!--
body {
margin-top: 2px;
}
-->
</style></HEAD>
<BODY>
<DIV class=centered>
<TABLE id=content>
<TBODY>
<TR>
<TD height="50" id=contentRight><p><strong>Direct Connect</strong></p>
<p><a href="Sales_Form.htm"onclick="openBrWindow('Sales_Form.htm','Sales Move in Move Out Form','status=0,scrollbars=1,resizable=1,width=400,height=300');return false" target="_blank">Move In Move Out Form</a></p>
</TD>
</TR>
</TBODY></TABLE>
<TABLE id=footer>
<TBODY>
<TR>
<TD>Copyright 2005 VE</TD>
</TR></TBODY></TABLE></DIV>
<SCRIPT language=JavaScript>
<!--
var SymRealOnLoad;
var SymRealOnUnload;

function SymOnUnload()
{
window.open = SymWinOpen;
if(SymRealOnUnload != null)
SymRealOnUnload();
}

function SymOnLoad()
{
if(SymRealOnLoad != null)
SymRealOnLoad();
window.open = SymRealWinOpen;
SymRealOnUnload = window.onunload;
window.onunload = SymOnUnload;
}

SymRealOnLoad = window.onload;
window.onload = SymOnLoad;

//-->
</SCRIPT>
</BODY></HTML>


Any help is appreciated, thanks

glenngv
05-23-2005, 12:14 PM
Spaces or other special characters are not allowed in window target. Remove the spaces or use underscore.

openBrWindow('Sales_Form.htm','Sales_Move_in Move_Out_Form','...');
You can also simplify it by passing this.href in the first parameter.

<a href="Sales_Form.htm" onclick="openBrWindow(this.href,...);
Modify the function as well so that the popup receives focus when it is opened.

function openBrWindow(theURL,winName,features)
{
var win=window.open(theURL,winName,features);
win.focus();
}
Try that and see how it goes.

ziguana_man
05-24-2005, 12:23 AM
I made all those amendments but still get the same null error, I get this when I load the page straight away but when i click on the link I get a different error: -

Line: 9 Char: 4 Error: Invalid Argument

Any other ideas?

Thanks in advance.

ziguana_man
05-24-2005, 12:24 AM
Line 9 is :-

var win=window.open(theURL,winName,features);

_Aerospace_Eng_
05-24-2005, 12:51 AM
Only reason I can think of why your code doesn't work is because of this bit here

<SCRIPT language=JavaScript>
<!--
var SymRealOnLoad;
var SymRealOnUnload;

function SymOnUnload()
{
window.open = SymWinOpen;
if(SymRealOnUnload != null)
SymRealOnUnload();
}

function SymOnLoad()
{
if(SymRealOnLoad != null)
SymRealOnLoad();
window.open = SymRealWinOpen;
SymRealOnUnload = window.onunload;
window.onunload = SymOnUnload;
}

SymRealOnLoad = window.onload;
window.onload = SymOnLoad;

//-->
</SCRIPT>
That comes from Norton Internet Security. If its in your current page, take it out and then resave it. It should work then.

ziguana_man
05-24-2005, 01:37 AM
My code now looks like this but I get the same errors, this one when I load the page 'line 9 Char 2 - 'Null' is null or not an object' and this one when I click the link 'Line: 9 Char: 4 Error: Invalid Argument'.

Code below, how to I indent the code like you guys are lol: -

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<!---->
<HTML><HEAD><TITLE>VE - Home</TITLE>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<script type="text/javascript">
<!--
function openBrWindow(theURL,winName,features)
{
var win=window.open(theURL,winName,features);
win.focus();
}
-->
</script>

<SCRIPT src="../VE%20-%20Home_files/library.js"
type=text/javascript></SCRIPT>

<SCRIPT src="../VE%20-%20Home_files/main.js"
type=text/javascript></SCRIPT>
<LINK href="../VE%20-%20Home_files/style.css" type=text/css
rel=stylesheet><LINK href="../icon.gif" type=image/gif rel=icon>
<META content="MSHTML 6.00.2900.2604" name=GENERATOR><style type="text/css">
<!--
body {
margin-top: 2px;
}
-->
</style></HEAD>
<BODY>
<DIV class=centered>
<TABLE id=content>
<TBODY>
<TR>
<TD height="50" id=contentRight><p><strong>Direct Connect</strong></p>
<p><a href="Sales_Form.htm"onclick="openBrWindow(this.href,'Sales_Move_in Move_Out_Form','status=0,scrollbars=1,resizable=1,width=400,height=300');return false" target="_blank">Move In Move Out Form</a></p>
</TD>
</TR>
</TBODY></TABLE>
<TABLE id=footer>
<TBODY>
<TR>
<TD>Copyright 2005 VE Pty Ltd</TD>
</TR></TBODY></TABLE></DIV>
</BODY></HTML>

glenngv
05-24-2005, 03:34 AM
The error might be coming from these:

<SCRIPT src="../VE%20-%20Home_files/library.js"
type=text/javascript></SCRIPT>

<SCRIPT src="../VE%20-%20Home_files/main.js"
type=text/javascript></SCRIPT>

Try running your page in Firefox to get more detailed error messages.

ziguana_man
05-24-2005, 03:52 AM
Works fine in firefox!! problem is my entire company is IE6 and I can't change this!

How can I fix this or debug it further?

_Aerospace_Eng_
05-24-2005, 04:12 AM
What is in these scripts?

<SCRIPT src="../VE%20-%20Home_files/library.js"
type=text/javascript></SCRIPT>

<SCRIPT src="../VE%20-%20Home_files/main.js"
type=text/javascript></SCRIPT>

ziguana_man
05-24-2005, 04:46 AM
function e(id) {
return document.getElementById(id);
}

function hasClass(element,className) {
classes = element.className.split(' ');
for (var i = 0; i < classes.length; i++) if (classes[i] == className) return true;
return false;
}

function addClass(element,className) {
classes = element.className.split(' ');
for (var i = 0; i < classes.length; i++) if (classes[i] == className) break;
classes[i] = className;
element.className = classes.join(' ');
}

function removeClass(element,className) {
classes = element.className.split(' ');
for (var i = 0; i < classes.length; i++) if (classes[i] == className) break;
classes[i] = null;
element.className = classes.join(' ');
}

function switchClass(element,className,classNameNew) {
classes = element.className.split(' ');
for (var i = 0; i < classes.length; i++) if (classes[i] == className) break;
if (i < classes.length) classes[i] = classNameNew;
element.className = classes.join(' ');
}

function getX(element) {
if (element.x) return element.x;
if (element.offsetParent) {
for (var x = 0; element.offsetParent; element = element.offsetParent) x += element.offsetLeft;
x += document.body.offsetLeft;
return x;
}
else return false;
}

function getY(element) {
if (element.y) return element.y;
if (element.offsetParent) {
for (var y = 0; element.offsetParent; element = element.offsetParent) y += element.offsetTop;
y += document.body.offsetTop;
return y;
}
else return false;
}

ziguana_man
05-24-2005, 04:47 AM
function initialise() {
navigationCurrent = null;
navigationTimeout = null;
initialiseNavigation();
}

function initialiseNavigation() {
n = e('navigation').getElementsByTagName('a');
for (var i = 0; i < n.length; i++) {
if (n[i].childrenNavigation = e('nc' + n[i].id.substring(1))) {
n[i].x = getX(n[i]);
n[i].y = getY(n[i]);
if (!i) n[i].y++; // move top item down 1 more pixel for neatness
n[i].childrenNavigation.style.left = (n[i].x + 240) + 'px'; // navigation block is 240px wide
n[i].childrenNavigation.style.top = (n[i].y - 1) + 'px';
addClass(n[i],'arrow1');
nc = n[i].childrenNavigation.getElementsByTagName('a');
for (var j = 0; j < nc.length; j++) {
nc[j].nID = n[i].id;
nc[j].onmouseover = navigationChildMouseover;
nc[j].onmouseout = navigationChildMouseout;
}
}
n[i].onmouseover = navigationMouseover;
n[i].onmouseout = navigationMouseout;
}
}

function navigationMouseover() {
if (navigationTimeout) clearTimeout(navigationTimeout);
if (navigationCurrent) navigationDeactivate(navigationCurrent);
navigationActivate(this.id);
}

function navigationMouseout() {
navigationTimeout = setTimeout('navigationDeactivate(\'' + this.id + '\')',5);
}

function navigationChildMouseover() {
if (navigationTimeout) clearTimeout(navigationTimeout);
navigationActivate(this.nID);
addClass(this,'highlight');
}

function navigationChildMouseout() {
removeClass(this,'highlight');
navigationTimeout = setTimeout('navigationDeactivate(\'' + this.nID + '\')',500);
}

function navigationActivate(navigationID) {
navigationCurrent = navigationID;
n = e(navigationID);
addClass(n,'highlight');
switchClass(n,'arrow1','arrow2');
if (n.childrenNavigation) n.childrenNavigation.style.visibility = 'visible';
}

function navigationDeactivate(navigationID) {
navigationCurrent = null;
n = e(navigationID);
removeClass(n,'highlight');
switchClass(n,'arrow2','arrow1');
if (n.childrenNavigation) n.childrenNavigation.style.visibility = 'hidden';
}

window.onload = initialise;

glenngv
05-24-2005, 05:34 AM
onclick="openBrWindow(this.href,'Sales_Move_in Move_Out_Form',...)You still had a space in the window target. That still causes the invalid argument error.

Regarding the null object error, try temporarily removing the library.js and main.js from the page to verify if the error is caused by those scripts.

ziguana_man
05-24-2005, 06:09 AM
I removed the .js files and the error no longer comes up when I load the page but when I click the link I get Line 9 Char 4 Error Access is denided.

The line is: -

var win=window.open(theURL,winName,features);

Harry Armadillo
05-24-2005, 06:15 AM
In main.js, the line

n = e('navigation').getElementsByTagName('a');

is looking for an element id'ed as 'navigation', and your page doesn't have one.

glenngv
05-24-2005, 09:03 AM
I removed the .js files and the error no longer comes up when I load the page but when I click the link I get Line 9 Char 4 Error Access is denided.

The line is: -

var win=window.open(theURL,winName,features);
Can you post a link to a sample or demo page so that we're testing the same page?

ziguana_man
05-25-2005, 04:30 AM
All working now, I removed the .js files and ftp'd it up and it works :)

Thanks for your help all.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum