Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-27-2009, 06:49 PM   PM User | #1
gilgalbiblewhee
Regular Coder

 
Join Date: Mar 2005
Posts: 735
Thanks: 4
Thanked 1 Time in 1 Post
gilgalbiblewhee is an unknown quantity at this point
redirect to javascript function

Is there a way to redirect a page to a JavaScript function:
PHP Code:
<?php
if($_GET["goto"]!==""){
    echo 
$_GET["goto"];
    echo 
"<input name=\"\" id=\"gotolink\"type=\"hidden\" value=\"".$_GET["goto"]."\" />\n";
    
//header("Location: index.php");
    
echo "<meta http-equiv='Refresh' content='0; url= \"JavaScript: gotolink();\"' />\n";
    
//echo "<meta http-equiv='Refresh' content='0; url= ../index.php' />\n";
}

?>
The point of this is let's say the url is this:
http://mywebsite.com/flashclips/hock...ips/hockey.php

I want the goto to be grabbed by the get method redirect to the index and using AJAX I want this extension:
goto=flashclips/hockey.php

to be appearing in the "main" div tag.
Code:
function createRequest(){
	var req = false;
	try {
		req = new ActiveXObject('Msxml2.XMLHTTP');
	} catch (e2) {
	try {
		req = new ActiveXObject('Microsoft.XMLHTTP');
	} catch (e3) {
		try {
			req = new XMLHttpRequest();
		} catch (e1) {
			req = false;
			}
		}
	}
	return req;
}

/*****************************************************************/
function getit(aid, aurl){
	var req = createRequest();
	if(req){
		req.onreadystatechange = function(){
			var c = document.getElementById(aid);
			if(req.readyState){
				if(req.readyState == 4){
					if(req.status == 200){
						c.innerHTML = req.responseText;
					}
				}
			}
		}
	req.open('GET', aurl, true);
	req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	req.send(null);
	}
}
function gotolink(){
       getit('maindiv','flashclips/hockey.php');
	location.href = "../index.php";
}
__________________
Compare bible texts (and other tools):
TheWheelofGod
gilgalbiblewhee is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:50 PM.


Advertisement
Log in to turn off these ads.