frames and $_GET

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

frames and $_GET

Post by s.dot »

Firstly, I don't know whether this belongs here or in Client Side.

I have a framepage that loads two basic frames. A top frame, and a bottom frame. What I'm wanting to do is have the bottom page stay the same, but the user should be able to navigate in the top frame. It works good except when a link in the top page uses $_GET.. such as they click on a link like page.php?foo=bar.. it then breaks my page out of frames and loads that page as the whole page.

I expected this.. because it has to know the URL in order to execute the PHP.. but is there any way around this? Is it possible to do?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

Moved to client side

use the target attribute of your anchor tag....
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

the bottom frame doesn't have any links... just the links in the top frame.. and i want them to open in the top frame.. not another 'target' frame.. if you know what I mean
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

so give your frame an id and a name and then use the target attribute to tell it where to open the page:

ex:

Code: Select all

<a href="whatever.php" target="topFrame">whatever</a>
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

whoa.. I thought you were way off base with your answer.. and didn't understand my question.. but it worked beautifullly :P congrats to you burrito man!

Now, on to a tougher question.. sometimes the top frame will be in a framed page, and other times it will be on a page by itself ( the user has the option to choose frames, or just view the top page of the frames in a page of its own)

Now, I'd hate to go through my WHOLE site, giving every link a target attribute.. that would be hard.. and very time consuming.

Is there a piece of code I can write.. or something.. that can check to see if there is frames, then if there is, give all A tags, a target attribute..

or would I have to do that manually?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

here's what I'd do:

I'd create a "preferences" section that allows the user to choose whether they want frames or not then store that preference in a session var.

you could then do an extended find and replace for all of your <a> tags and add something like this:

Code: Select all

<a href="blah.php" <?php echo ($_SESSION['frames'] == 'yes' ? "target=\"topFrame\"" : "");?>>link</a>
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

okay.. well I basically gave you a general scenario earlier.. so here's the real situation.

I'm implementing a 'chatbar' feature of my website.. for users who want to chat and browse the site at the same time. when they go to the frame page (chatbar.html) the top frame is the rest of the site, and the bottom page is the chat.. so they can chat and browse at the same time.. so I don't really think a session would be fit because it's not really their 'preference' so to speak..

I guess when they load chatbar.html I could update a field in my database that would tell the php page it's using frames.. then how would I do the find and replace on a whole page, without manually editing each link?

What about CSS, can you give links a target in the css?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

scrotaye wrote:What about CSS, can you give links a target in the css?
I'm going to say with 95% certainty that you can not.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

I'll add the other 5% :)

you could use your flagged field on the db idea and if it's flagged, then do what I posted above to "inject" the target into the links.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Code: Select all

<a href="blah.php" <?php echo ($_SESSION['frames'] == 'yes' ? "target=\"topFrame\"" : "");?>>link</a>
I'll be blunt.. what exactly does this do? how do I use it, and where do I put it? =/ I've never used something like this in my code. Would someone please explain it to me :-D
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

it's the ternary operator:

go here and look about a sixth of the way down the page for "Ternary Operator".

Basically it's an if / else but much more concise.

in the case that I wrote it would compare to this:

Code: Select all

if($_SESSION['frames'] == "yes")
  echo "target=\"topFrame\"";
else
  echo "";
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

ah, understood.

so i'd have to place this code manually into all of the link tags?
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

Post by Burrito »

or do as I suggested and do an extended find and replace to do it...if your editor doesn't have an extended find and replace...you need a new editor :?
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

I could do that.. but not all links look the same.. I guess I could do

Code: Select all

<a <? insert your ternary operator here ?> href="blah.php">link</a>
a bit backwards from how I usually do things, but it should work.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
User avatar
n00b Saibot
DevNet Resident
Posts: 1452
Joined: Fri Dec 24, 2004 2:59 am
Location: Lucknow, UP, India
Contact:

Post by n00b Saibot »

you can add the target attribute to the links on the fly using DOM :wink:
Post Reply