LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-11-2006, 07:40 PM   #1
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Rep: Reputation: 65
CSS - Using "target" switch help


Hi there!

I've been playing once again with CSS (I promise I will learn it someday), and so far I have this:

http://goto.glocalnet.net/torch

it looks bad, I know. The problem is, I want to simulate frames. So far, it is working fine. I'm having problems adding a header/footer, but I will get to it later.

What I want to do, however, is something like this: If the visitor clicks on the link "about", instead of reloading the whole page, only the content should change. I know I have to use the target-switch and I have even done it once before, but I can't get it right.

Does anyone have an example how I may accomplish this? Nothing fancy or over complicated. I've been trying to find this info on google for a while, but it is not so easy to find as I thought.

Anyway, thanks in advance!
 
Old 07-11-2006, 08:30 PM   #2
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
Do you mean the target attribute for anchor elements? This isn't a part of the strict XHTML standards "because frames and windows are outside the scope of pure document markup" (Danny Goodman, Dynamic HTML, O'Reilly). I'm not sure it would work anyways, since you're using a DIV (not a frame) to contain the stuff you want to change.

You could use some AJAX magic, which is really geared towards this sort of problem, but then it wouldn't work in all browsers.
 
Old 07-11-2006, 09:39 PM   #3
AdaHacker
Member
 
Registered: Oct 2001
Location: Brockport, NY
Distribution: Kubuntu
Posts: 384

Rep: Reputation: 32
Sorry, but you simply can't do that. CSS can simulate the look and visual behavior of frames, but not the reloading aspect. You'll have to either use frames or live with the full page reload.
 
Old 07-12-2006, 12:26 AM   #4
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Original Poster
Rep: Reputation: 65
Thanks guys!

Heck, I wonder how I've managed to do that. Maybe I used a jsp include before or something like that. Sad I've lost all my work and did have backup. Our SVN server is down, otherwise I could check how I have done that.
 
Old 07-12-2006, 01:53 PM   #5
LinuxLala
Senior Member
 
Registered: Aug 2003
Location: New Delhi, India
Distribution: Fedora 7
Posts: 1,305

Rep: Reputation: 45
Mega Man X, I am not sure I completely understand what you want as I was unable to browse your site. But, I would suggest you have a look at my site (http://www.linuxlala.net) The buttons that you see were made in CSS. When you click on any button, the page doesn't reload, but the specific content is displayed. Please try it.

It is possible using simple CSS and javascript. Maybe you want to do this.
 
Old 07-12-2006, 05:54 PM   #6
taylor_venable
Member
 
Registered: Jun 2005
Location: Indiana, USA
Distribution: OpenBSD, Ubuntu
Posts: 892

Rep: Reputation: 43
LinuxLala: I hope you don't mind that I make two comments about the method that you use to change content without reloading. (Please don't take this as an insult; I just want to point them out for the sake of argument.) First is that while the user never has to reload the page, all the content that can possibly be viewed has been downloaded to the client at once. If you had a very large website this could be somewhat troublesome, especially to those on slow connections. Second is the use of JavaScript, which is not inherently bad, but one does have to keep in mind the capabilities of the client. Some people may have JS turned off, especially for sites they don't know well or trust fully. Or some clients might not have JavaScript available to them.

You've gotten around some of the problems with JavaScript wonderfully by using visibility settings, which makes your site look just fine in Lynx. But then if you had a large site this could again cause problems. AJAX can help get around that issue of having the client downloading everything on the site at once. The problem then becomes that AJAX relies on JavaScript which if disabled will pose a greater problem when the client can't see anything at all.

Mega Man X: In light of the above, I'd recommend trying this if at all possible -- (I used to use this on my blog and I've tested it from as many angles as I could so it should work.) Use AJAX to change the content in the DIV using JavaScript and some server-side scripting. That way the client only downloads what they need. Then if the client has JS disabled, you can provide a <noscript> block which will alternatively be a set of normal links to the content pages. If you use server-side scripting like PHP to generate your pages, you can do this without having duplication of your content (on the server). And you can generate fully standards-compliant XHTML and CSS.
 
Old 07-17-2006, 01:35 PM   #7
Mega Man X
LQ Guru
 
Registered: Apr 2003
Location: ~
Distribution: Ubuntu, FreeBSD, Solaris, DSL
Posts: 5,339

Original Poster
Rep: Reputation: 65
Thanks again for the replies and sorry for my late reply ^_^;

@LinuxLala

Very nice mate. This is actually what I'm trying to accomplish. It sounds ratter complicated for my limited knowledge of Jscript and CSS though, but I will give it a shot. I will have to wait until the weekend though

@taylor_venable

Thanks for pointing the drawbacks of using Javascript. I personally never tried Javascript for more than a day myself ^_^. I don't think it would affect me much, since it is not (going to be) an important site, nor I believe that the visitors (if any, really) will have js disabled
 
Old 07-18-2006, 05:44 AM   #8
LinuxLala
Senior Member
 
Registered: Aug 2003
Location: New Delhi, India
Distribution: Fedora 7
Posts: 1,305

Rep: Reputation: 45
taylor_venable: you are absolutely right. The entire page needs to load before one can start browsing. The place I learned this trick from (http://www.cssinsider.com) actually also mentioned this as a hassle. But, I used it anyway as my page only has text, and not too much of it

I too would like to try this with AJAX. That'd be fun.

megaman: not complicated at all. About 4 lines is all it needs.

P.S. I didn't get any notification mail when you replied on the 13th. Just got one today when megaman replied. I'd wait a while and then maybe post this in WQnA.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
"NIM thread blocked" & "Deadman Switch (DMS) close to trigger" errors sosborne Linux - Networking 1 06-28-2006 02:07 PM
"NIM thread blocked" & "Deadman Switch" errors sosborne AIX 3 06-01-2006 11:21 AM
Can I run a port scan to a "target" machine from the internet? NuxIT Linux - Networking 9 05-18-2006 06:20 AM
CSS question "change color of button" ALInux Programming 2 04-14-2006 10:40 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration