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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Resolution Dependent Links

Status
Not open for further replies.

Geronantimo

Technical User
Apr 3, 2006
79
0
0
SE
I have searched, but found nothing...

Is it possible to create a link that will go to a different destination based on the browser size or screen resolution?

 
with javascript? sure. but you'll need to make sure your visitors have javascript enabled.

the real answer is "develop your websites so they are browser-independent".



*cLFlaVA
----------------------------
[tt]"quote goes here"[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
cLFlaVA <quote>
the real answer is "develop your websites so they are browser-independent".

* and resolution-independent.
</quote>

You are absolutely right!

However, with some 90%+ of web users having JavaScript turned on, it is quite sensible to be using JavaScript to customise delivery according to a user's particular settings.

Many sites that are browser / resolution independent look dreadful on my screen resolution of 1600 x 1200 and likewise, there are many sites that look dreadful on 800 x 600.

Where users do not have JavaScript turned on, I can use the <noscript> tag to send them to the "vanilla" version that accommodates everyone.

That said, can anybody direct me as to how to create a JavaScript link that will direct users in different directions according to their resolution / browser size?

Regards,
 
there are a few methods...

you can use the document.write to write the anchor tag to the file while the page loads. you could also call a function AFTER the page loads to determine the window size and change the anchor href.

take a look at this article about window properties:
use a typical document.getElementById to capture a handle on the anchor tag, then change the .href property based on your screen resolution test results.



*cLFlaVA
----------------------------
[tt]"quote goes here"[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top