View Full Version : window.location.search question

08-10-2006, 10:26 PM
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";

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 "http://www.mysite.com/news/showarticle.asp?ArticleID=4162" 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);}

Does anyone has any ideas how to make it work? Thanks in advance for any help.

08-11-2006, 02:45 AM
You left out the ? between the page name and the search string.

window.location.replace("showArticle2.asp?" + window.location.search

The other thing you need to do is to change it to test the width inside the browser window instead of the screen width since someone with a screen width of 2000 may have their browser open using only say 500 of that width so as to see other things at the same time.