[SOLVED ] open new window

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

[SOLVED ] open new window

Post by ol4pr0 »

The following code does open up a new window however with the following error
The requested URL /user/undefined was not found on this server.

Code: Select all

<script language="JavaScript">
                <!--
                        function abrirVentana(theURL)
                        &#123;
                                var cadena;
                                var ancho, alto;
                                ancho = screen.availWidth - 10;
                                alto = screen.availHeight - 50;
                                cadena = 'left=0,top=0,border=0,status=yes,scrollbars=no,toolbar=no,menubar=no,location=no,resizable=yes,' + 'width=' + ancho + ',height=' + alto;
                                window.open(theURL, "indexsecure.php", cadena);
                        &#125;
                                                                                                                             
                        function CargaString()
                        &#123;
                                window.status = "Welcome to ..........;
                                var yourname = getCookie("USERNAME");
                                if (yourname != null)
                                &#123;
                                        //Ha cargado el sitio previamente
                                        Tiempo = setTimeout("abrirVentana('indexsecure.php')", 500);
                                &#125;
                                else
                                &#123;
                                        //No ha cargado el sitio previamente
                                        register("USERNAME");
                                        Tiempo = setTimeout("abrirVentana('indexsecure.php')", 500);
                                &#125;
                        &#125;
abrirVentana();
CargaString();
//-->
Last edited by ol4pr0 on Fri Apr 16, 2004 5:07 pm, edited 1 time in total.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

function abrirVentana(theURL) .. looks like you have to pass it a url but you are just doing, abrirVentana(); *shrug*
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

I have great fath in you when it comes to db.s and some other php coding however.. in this.. case i dont think that will work. (* but i will give it a try .. and get back )

EDIT : sorry didnt work..

funcition openWindow() has..

theURL, "indexsecure.php", ;-) but something goes wrong there i think.
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

Well, looking at it again, function abrirVentana(theURL) does require a url to be passed in, but it's being called from function CargaString() like this,
abrirVentana('indexsecure.php') .. so it does pass in a url ;)
So i'm not sure you should be calling both
abrirVentana();
CargaString();
but maybe just CargaString();

Not sure what function openWindow() is that you mention above as you don't mention it in your original post :o
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Yea i did.. the abrirVentana Goes well..


however CargaSTring doesnt do so fine..

abrirVentana => openWindow ;-) spanish => English ;-)
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

let me translate some of all of it and maby you understand some more.. of the script.
besides the java part i mean...

Code: Select all

function openWindow(theURL)
                        {
                                var cadena;
                                var ancho, alto;
                                ancho = screen.availWidth - 10;
                                alto = screen.availHeight - 50;
                                cadena = 'left=0,top=0,border=0,status=yes,scrollbars=no,toolbar=no,menubar=no,location=no,resizable=yes,' + 'width=' + ancho + ',height=' + alto;
                                window.open(theURL, "for title bar ...  ", cadena);
                        }
                                                                                                                             
                        function CargaString()
                        {
                                window.status = "Welcome to ..........;
                                var yourname = getCookie("USERNAME");
                                if (yourname != null)
                                {
                                        //Ha cargado el sitio previamente
                                        // meaning cookie did got set..
                                        Tiempo = setTimeout("openWindow('indexsecure.php')", 500);
                                }
                                else
                                {
                                        //No ha cargado el sitio previamente
                                        // meaning cookie didnt got set "GO BACK TO START  "
                                        register("USERNAME");
                                        Tiempo = setTimeout("openWindow('indexsecure0.php')", 500);
                                }
                        }

//-->
</script>
</head>
<? echo $_COOKIE['USERNAME']; ?> // does echo back the cookie 

// /here it stops doing its job.

<body onload="CargaString();" bgcolor="#5d5d60" marginwidth="0" marginheight="0" topmargin="0" leftmargin="0">
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

window.status = "Welcome to ..........;
no end string terminator.
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Nice noticing that .. however it does still produce this error
The requested URL /user/undefined was not found on this server.
=====================================================
Apache/1.3.29 Server at localhost.localhost Port 443
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

maybe getCookie() isn't actually a function?
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

Sorry for letting that out.. however it is there, and produces the error as displayed above

Code: Select all

function getCookie(Name)
                        &#123;
                                var search = Name + "="   
                                if (document.cookie.length > 0)
                                &#123; // if there are any cookies
                                        offset = document.cookie.indexOf(search)
                                        if (offset != -1)
                                        &#123; // if cookie exists          
                                                offset += search.length          
                                                        // set index of beginning of value         
                                                end = document.cookie.indexOf(";", offset)          
                                                        // set index of end of cookie value         
                                                if (end == -1)             
                                                        end = document.cookie.length         
                                                return unescape(document.cookie.substring(offset, end))      
                                        &#125;    
                                &#125;
                        &#125;
;-)
User avatar
ol4pr0
Forum Regular
Posts: 926
Joined: Thu Jan 08, 2004 11:22 am
Location: ecuador

Post by ol4pr0 »

I would almost like to say copy the code and try it youreself to see what i mean

edit:

all fixed thanks for all the help ;-)
Post Reply