Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,153,110 members, 7,818,311 topics. Date: Sunday, 05 May 2024 at 12:24 PM

What Could Be Wrong With This Javascript Code - Programming - Nairaland

Nairaland Forum / Science/Technology / Programming / What Could Be Wrong With This Javascript Code (1002 Views)

Adding Validation To Javascript Code / Please I Need Help - Evaluating A Javascript Code Line By Line / Javascript Code Autocomplete In Webpage (2) (3) (4)

(1) (Reply) (Go Down)

What Could Be Wrong With This Javascript Code by talk2hb1(m): 2:01pm On Mar 04, 2013
Help please I am trying to create a JavaScript that open a child window, I want to be redirected to another location when the child window is closed and it is not working, firebug is not helping either.


<html>
<head>
<title>Testing the open script</title>
<script language="Javascript" type="application/javascript">
//var drupal = null;
var drupal =null;
//function winopener(){
drupal = window.open("http://127.0.0.1/test.php","testwin",200,200);

//}

//winopener();
if(drupal.closed){
//alert("Window closed safely"wink;
location="http://localhost/somewhere/";
}
</script>
</head>
<body>
<h1> This is just it</h1>
<p> URL
The URL of the page to open in the new window. This argument could be blank.

windowName
A name to be given to the new window. The name can be used to refer this window again.

windowFeatures
A string that determines the various window features to be included in the popup window (like status bar, address bar etc)

The following code opens a new browser window with standard features.</p>
</body>
</html>


<<<<<<<<<<<<<<<<<<<<<<<<<<test.php>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<?php
echo "<h2> Testing the inner window of the javascript class</h2>";
echo "<p> URL
The URL of the page to open in the new window. This argument could be blank.

windowName
A name to be given to the new window. The name can be used to refer this window again.

windowFeatures
A string that determines the various window features to be included in the popup window (like status bar, address bar etc)

The following code opens a new browser window with standard features.</p>";
?>



Please what could be wrong with the code??
Re: What Could Be Wrong With This Javascript Code by hoodboi(m): 9:07pm On Mar 04, 2013
I haven't tested your code yet, but why don't u change d location keyword to url = "new site" nd also is the alert box displaying on window close? If its not as well, den d prblm must be frm d if condition
Re: What Could Be Wrong With This Javascript Code by greatdeveloper(m): 6:36pm On Mar 05, 2013
With what am seeinng in your code, you are commenting out the function you are creating and also the call of the function is being commennted out.
Try and modify your code
If persist attach the code and send it to my email greatdeveloperp@gmail.com
I will modify and explain the code further for you
Re: What Could Be Wrong With This Javascript Code by Capnd143(m): 8:10pm On Mar 05, 2013
Well i think the function is nt being executed when called because you told the browser to ignore the existence of the function bt rather treat it as a text. Me thinking. Because of the comment tags e.g //function myfunction() {do.this() }//
Re: What Could Be Wrong With This Javascript Code by talk2hb1(m): 12:30pm On Mar 08, 2013
Thanks everyone,
I have manged to solve the problem, and this is the final code.

index.php
<code>
<html>
<head>
<title>Testing the open script</title>
<script language="Javascript" type="application/javascript">

win = open('http://127.0.0.1/test.php',"testwin",200,200);

function go(){
window.location.href = "http://127.0.0.1/drupal/";
}
</script>
</head>
<body>
<h1> This is just it</h1>
<p> URL
The URL of the page to open in the new window. This argument could be blank.

windowName
A name to be given to the new window. The name can be used to refer this window again.

windowFeatures
A string that determines the various window features to be included in the popup window (like status bar, address bar etc)

The following code opens a new browser window with standard features.</p>
</body>
</html>
</code>

test.php
<code>

<html>
<head>
<script language="Javascript">

function refreshParent()
{
opener.go();
}
</script>
</head>
<body onunload="javascript:refreshParent()">

<?php
echo "<h2> Testing the inner window of the javascript class</h2>";
echo "<p> URL
The URL of the page to open in the new window. This argument could be blank.

windowName
A name to be given to the new window. The name can be used to refer this window again.

windowFeatures
A string that determines the various window features to be included in the popup window (like status bar, address bar etc)

The following code opens a new browser window with standard features.</p>";
?>
</body>
</html>

</code>

(1) (Reply)

Utility Plugin / [MOD] PHP Workouts-email Validation In Php Using Any Method. / Website Review

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 22
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.