Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

window.location.search question

Status
Not open for further replies.

dmaier

MIS
Apr 13, 2002
38
US
I have a site that I am creating pages that adapt to different screen sizes. I am using a script for the regular pages that works like this:
<script language="Javascript"><!--
if (screen.width < 1000) {
document.location = "showArticle2.asp";
}
//-->
</script>

Some of the pages have news stories that come from a database and typically the regular page would load something like this:

What I want to do since the main page uses the " is to call the alternate page as shown above but it will do me no good unless I can ArticleID 4162.

I tried this but it does not work:
<script language="Javascript">
if (screen.width < 400)
window.location.replace("showArticle2.asp" + window.location.search);}
//-->
</script>

Does anyone has any ideas how to make it work? Thanks in advance for any help.
 
I just tried this, for some reason it doesn't seem to work. It just loads the regular page and not the new page.
 
Maybe something else is causing it to break. Use an alert instead to see if it's even running the script:
Code:
<script type="text/javascript">
if (screen.width < 400) {
  alert("showArticle2.asp" + window.location.search);
}</script>
This will also allow you to confirm the correct url is being generated.

Cheers,
Jeff

[tt]Jeff's Page @ Code Couch
[/tt]

What is Javascript? FAQ216-6094
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top