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

link problem

Status
Not open for further replies.

cajchris

Programmer
Oct 13, 2005
57
GB
hi,

i have an ahref link within my page which when clicked will call a javascript function to switch css files. this works fine however i want the new page to appear in a new window. i have tried using the target="_blank" attribute but it doesnt seem to do anything.

I would even settle for being able to use the back button on the browser to return to the page with the CSS before it was switched. here is my javascript function:

// activeCSS: Set the active stylesheet
function activeCSS(title) {
var i, oneLink;
for (i = 0; (oneLink = document.getElementsByTagName("link")); i++) {
if (oneLink.getAttribute("title") && findWord("stylesheet", oneLink.getAttribute("rel"))) {
oneLink.disabled = true;
if (oneLink.getAttribute("title") == title) {
oneLink.disabled = false;
}
}
}
}

// findWord: Used to find a full word (needle) in a string (haystack)
function findWord(needle, haystack) {
return haystack.match(needle + "\\b");
}

and here is my html:

<a href="/infoglueDeliverWorking/about" class="PrintIconLink" onclick="activeCSS('print');
return false;">

the url is the same as the url you are at before the link was clicked so essentially just ahref="".

regards,
cajchris
 
here's some simple jsp code. I've never used infoglue/velocity, so it may not be appropriate.
Code:
<head>

[COLOR=blue]<% if (request.getParameter("print")=="1") { %>[/color]
<link rel="stylesheet" type="text/css" href="print.css" />
[COLOR=blue]<% } else { %>[/color]
<link rel="stylesheet" type="text/css" href="normal.css" />
[COLOR=blue]<% } %>[/color]

</head>

To activate, all you'd need is a link: <a href="?print=1">print view</a>.

<marc>
New to Tek-Tips? Get better answers - faq581-3339
 
cajchris said:
thats good to know, cheers manarth but what if this is a client requirement that they have a print this page link which shows the page as it will be printed.

That is what "Print preview" in the browser is for. Stop trying to code functionality for users that they already have!

Dan

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top