logo-dw

Go Back   Dreamweaver Club Forums > Hand Coders Forum > Javascript and JS frameworks
Register FAQ Members List Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Display Modes
Old 04-29-2008, 08:07 AM   #1
student101
 
Join Date: Dec 2007
Posts: 379
Question URL problems?

When using frames, javascript, dhtml, ajax or anything else that is possible.
This script below will load the main page (in this case index.php) as the master page and the frame/page/div will load accordingly.
PHP Code:
<script type="text/javascript">
<!--
if (
self == top){
var 
url self.location;
self.location "index.php?" url;
}
// -->
</script> 
The PROBLEM:
The URL that gets created is the actual problem.
If I add this in the page called links.php
I load the links.php and the browser's URL looks like this:
Code:
http://localhost:81/site/index.php?http://localhost:81/site/links.php
All I need is the URL to be like this:
Code:
http://localhost:81/site/index.php
Is there a better or other way of doing this?
Cheers
__________________
Amateurs ... Built the ark.
Professionals ... Built the Titanic.
specificity [sound like spe-sifis-ity]
student101 is offline   Reply With Quote
Old 04-29-2008, 05:52 PM   #2
pete
 
Join Date: Apr 2008
Location: in a bin
Posts: 113
Default

Change it to:

PHP Code:
<script type="text/javascript">
<!--
if(
self == topself.location "index.php";
// -->
</script> 
pete is offline   Reply With Quote
Old 04-29-2008, 06:21 PM   #3
student101
 
Join Date: Dec 2007
Posts: 379
Default

I have tried that method but it wont load the page needed to load.

If I load links.php then your method will only load index.php and not the links.php page

Cheers
__________________
Amateurs ... Built the ark.
Professionals ... Built the Titanic.
specificity [sound like spe-sifis-ity]
student101 is offline   Reply With Quote
Old 04-29-2008, 06:25 PM   #4
pete
 
Join Date: Apr 2008
Location: in a bin
Posts: 113
Default

Quote:
Originally Posted by student101 View Post
I have tried that method but it wont load the page needed to load.

If I load links.php then your method will only load index.php and not the links.php page

Cheers
Of course, that is what you asked for.

Quote:
When using frames, javascript, dhtml, ajax or anything else that is possible.
This script below will load the main page (in this case index.php) as the master page and the frame/page/div will load accordingly.
The above makes no sense, can you post a page because from the above I am unclear what you are wanting to achieve.
pete is offline   Reply With Quote
Old 04-29-2008, 06:42 PM   #5
student101
 
Join Date: Dec 2007
Posts: 379
Smile

I have attached the files for you to see what I mean.

If you try to load one of the external.htm files it does not load the main index.htm

Cheers
Attached Files
File Type: zip ajaxcars1.zip (41.0 KB, 2 views)
__________________
Amateurs ... Built the ark.
Professionals ... Built the Titanic.
specificity [sound like spe-sifis-ity]
student101 is offline   Reply With Quote
Old 04-29-2008, 07:06 PM   #6
pete
 
Join Date: Apr 2008
Location: in a bin
Posts: 113
Default

In each external in ajaxfiles/ directory put the following JS

HTML Code:
<script type="text/javascript">
if(location.href.indexOf("ajaxfiles")>-1){
    location.href='../index.htm?uri=external.htm';
}
</script>

Change the uri to the name of the external page.

In index.htm add the following code:

HTML Code:
window.onload = function(){
    if(location.search.indexOf('uri=')>-1){
        var loc = location.search.split('=');
        ajaxpage('ajaxfiles/'+loc[1]+"","rightcolumn");
    }
}
Then if someone navigates to external.htm they get redirected to ajaxcars/index.htm?uri=external.htm and it loads that page.

Is that what you wanted?
pete is offline   Reply With Quote
Old 04-29-2008, 07:07 PM   #7
student101
 
Join Date: Dec 2007
Posts: 379
Default

I will try it right now.

That works great, how to fix the uri or URL to display only the index.htm
Code:
http://localhost:81/ajaxfiles/index.htm?uri=external.htm
from that to this: (and load still the external.htm file that was asked for)
Code:
http://localhost:81/ajaxfiles/index.htm
If it's possible then cool/bonus/great - if not then it's no train smash.

How did you figure that out? That's damn cool to just know it when you see it.

Cheers
__________________
Amateurs ... Built the ark.
Professionals ... Built the Titanic.
specificity [sound like spe-sifis-ity]

Last edited by student101; 04-29-2008 at 07:13 PM..
student101 is offline   Reply With Quote
Old 04-29-2008, 07:10 PM   #8
pete
 
Join Date: Apr 2008
Location: in a bin
Posts: 113
Default

Example

http://www.codecreate.co.uk/ajaxcars/index.htm
pete is offline   Reply With Quote
Old 04-29-2008, 07:16 PM   #9
student101
 
Join Date: Dec 2007
Posts: 379
Thumbs up

What am I looking for?

Here is my PHP version of this Axaj/dHTML/javacsript stuff:
PHP Code:
$allowed = array('index.php',
                 
'links.php',
                 
'contact.php',
                 
'home.php'
                 
);
                 
if(
in_array($_GET['pathid'], $allowed))
{
if(isset(
$_GET['pathid'])) 
include(
'./'.$_GET['pathid']); 
//include($_GET['pathid']);
}else{
// error do nothing except tell them off in a nice way.
echo "<BR>";
echo 
"<BR>";
echo 
"Busted, got you this time!";


Cheers and Thanks



__________________
Amateurs ... Built the ark.
Professionals ... Built the Titanic.
specificity [sound like spe-sifis-ity]

Last edited by student101; 04-29-2008 at 07:38 PM..
student101 is offline   Reply With Quote
Old 04-29-2008, 07:35 PM   #10
pete
 
Join Date: Apr 2008
Location: in a bin
Posts: 113
Default

Quote:
Originally Posted by student101 View Post
I will try it right now.

That works great, how to fix the uri or URL to display only the index.htm
Code:
http://localhost:81/ajaxfiles/index.htm?uri=external.htm
from that to this: (and load still the external.htm file that was asked for)
Code:
http://localhost:81/ajaxfiles/index.htm
If it's possible then cool/bonus/great - if not then it's no train smash.

Cheers
You need the link in the url unless you use PHP or similar then you can do tricks with sessions.

The script you have is actually not ideal, I would never expose or even create static pages in ajaxfiles/ like that. It is much better to use JSON and fill place holders rather than ram in static pages, you may as well use an iframe in this example. This is a perfect example of XHR (ajax is the name a marketing guy gave it, use XHR instead ) used incorrectly.
pete is offline   Reply With Quote
Reply


Thread Tools
Display Modes

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. The time now is 10:51 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com