Click to See Complete Forum and Search --> : INDEX or HOME PAGE SWAP (DYNAMIC)


Rockwell
03-25-2005, 07:09 PM
Hi guys,

This is my first post and I'm not positive if this is a DHTML or AN HTML question, or JavaScript, for that matter, but....!

Say I have 7 different home pages for my site and I want them to load randomly, so if you hit the refresh bar you'd pull up a different home page. This is something I've accomplished with IFRAMEs, but that comes with other problems that come with frames generally.

So... I was either looking for a way to do this that didn't require frames or if anyone has a tip on how to create links that ditch the frame altogether that would work as well.

Bare in mind, I'm talking about 7 .htm pages, not areas on one page I'd like to populate with distinct content, so in a way, it's a simple thing I'm trying to accomplish and not an ASP situation.

Thanks!
R*Well

phpnovice
03-25-2005, 07:15 PM
Ideally, this is still an ASP/PHP solution. You create a default.asp (or whatever) page for your site and it randomly serves up the content of one of your .htm pages. Otherwise, you're pretty much stuck with:

DHTML = JavaScript

Rockwell
03-25-2005, 07:17 PM
Ideally, this is still an ASP/PHP solution. You create a default.asp (or whatever) page for your site and it randomly serves up the content of one of your .htm pages. Otherwise, you're pretty much stuck with:

DHTML = JavaScript
Thanks for the reply. Sounds like you don't like the DHTML/JS route. I'll do some research on ASP, as its new to me, but if you see this again and are able to link me in the right direction that'd be great -- and just a quick question: ASP would be middle ware, right? So I have to set my server up to play nice with it?

R*Well

MstrBob
03-25-2005, 07:45 PM
Middle ware? ASP, PHP, JSP, these are server-side technologies. The server executes scripts written in these, and sends the result. Be aware that there's more then just ASP available. THere's also PHP, .Net, JSP, Perl, Python, and others. Consider your past programming experience, and what your host may already support.

phpnovice
03-25-2005, 09:09 PM
Thanks for the reply. Sounds like you don't like the DHTML/JS route.
You misjudge me. ;) I am a master-level JavaScripter -- tested and certified at BrainBench.com (at one time). At the same time, though, I am a highly advanced-level ASP programmer (not a master) and have been adding PHP expertise to my portfolio for the last several months.

I used that word "stuck" only because I believe that every programming language has its place. I do NOT believe that choices about programming language should be strictly governed by things like "accessibility". AT THE SAME TIME, I am not insensitive to those who have those needs. Instead, I believe in each person's right to use whatever programming language they chose -- even if that means someone may not be able to access their site. If the person creating the site wants it to be fully accessible then, quite naturally, they will have to restrict their choices accordingly. But, again, it should be about choice -- not about force.

"He that hath an ear, let him hear" and understand.

ray326
03-25-2005, 10:08 PM
You could easily do that with Javascript on your index.html that randomly redirected to one of your various home pages.

Rockwell
03-26-2005, 12:26 AM
You misjudge me. ;) I am a master-level JavaScripter -- tested and certified at BrainBench.com (at one time).

No, I just meant that you thought maybe the ASP might be more streamline, but I hear what you're saying about getting a good match and thanks, it's good advice.

Ray 326, you mentioned a jS redirect -- does that create a perciptible halt or is fast?
R*Well

phpnovice
03-26-2005, 12:46 AM
No, I just meant that you thought maybe the ASP might be more streamline...
Let's just say that if you think your site has the potential to be visited by those whose browsers won't execute your JavaScript, then you probably ought to keep a high priority towards using server-side technology for your code and HTML/CSS only on the client side.

As for JavaScript, the redirect would be immediate. Something like this:

var pages = new Array(
"index1.htm",
"index2.htm",
"index3.htm",
"index4.htm",
"index5.htm",
"index6.htm",
"index7.htm"
); // no comma after last entry above
self.location.href = pages[Math.floor(Math.random() * pages.length)];