Jeff said the following on 12/24/2006 10:57 AM:
>
I'm very new to javascript and need only a small amount in an asp.net
application I'm working on. I apologize if I'm not using the correct
terminology to describe the problem.
I got the code below to work under most conditions to capture the
client's screen resolution and then redirect to another page (but there
likely are better ways to code this).
Why is the resolution even important? Unless you intend to resize the
window itself I have never understood it's importance unless the
resulting page deals with desktop items or the such.
This needs to work under 3 conditions;
A) if the current top.location.href is similar to www.hhh/
B) if the current top.location.href is similar to www.hhh/?user=xxx and
C) if the current top.location.href is similar to www.hhh/default.apsx
It almost seems pedantic, but you have to define "is similar".
The code below works for situation A and B, but not C. In other words, I
need to redirect to
www.hhh/Prelim/00bPreliminary.aspx
and not to www.hhh/default.aspxPrelim/00bPreliminary.aspx
What would be the initial URL that you need to redirect from? Without
knowing that, a person can only guess as to how to fix the code.
(while also passing the screen resolution and username if there is one).
Can someone please show me what I'm missing to get rid of the
default.aspx if it is there, or to write this in a better manner?
y = top.location.pathname.replace('default.aspx','')
Will remove default.aspx from the location, which is what you are saying
you want to do.
<script type = "text/javascript" >
<!--
{
res = "res="+screen.width+"x"+screen.height;
y = top.location.pathname ;
It may, or may not, be possible in your application but beware that
top.location.pathname will give erroneous results if your page gets
"framed". document.location.pathname is a safer route, then set
top.location.href and it will bust out of any potential framed situations.
--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -
http://jibbering.com/faq/index.html
Javascript Best Practices -
http://www.JavascriptToolbox.com/bestpractices/