Killersites.com Homepage Welcome Guest   |   Register  |  Login
Login Name Password
  Search  
  Index  | Recent Threads  | Unanswered Threads  | Who's Online  | User List  | Help


Quick Go »

No member browsing this thread
Thread Status: Active
Total posts in this thread: 9
[ Jump to Last Post ]
Post new Thread
Author
Previous Thread This topic has been viewed 7604 times and has 8 replies Next Thread
Male shelfimage
Advanced Member
Member's Avatar

USA
Joined: Mar 24, 2005
Post Count: 3000
Status: Offline
Reply to this Post  Reply with Quote 
confused Javascript needed for Print this page -w/out using onClick=""

Hi All!

Thanks to davidmead, I've been using js to open new windows using rel="external" in the <a></a> tag instead of target="_blank"

The script is:
function externalLinks() {
if (!document.getElementsByTagName) return;
var anchors = document.getElementsByTagName("a");
for (var i=0; i<anchors.length; i++) {
var anchor = anchors;
if (anchor.getAttribute("href") &&
anchor.getAttribute("rel") == "external")
anchor.target = "_blank";
}
}
window.onload = externalLinks;

Name it newwindow.js or something; call it from the header
<script type="text/javascript" src="newwindow.js"></script>
and trigger it from a link;
<a href="something.html" title="something" rel="external">some link</a>

Easy as pie.


So, I'm trying find the same for a javascript print function.

I'd like to be able to the following:
<a href="#" title="something" rel="print">Print this page</a>

instead of doing this:
<a href="#" onClick="window.print(); return false" title="Print this page">Print this page</a>

I haven't found anything on the Internet yet and my attempts to mess around with the script above have failed.

TIA for any suggestions!
-
----------------------------------------
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo
Save the developers<!>
Maine Webworks
----------------------------------------
[Edit 2 times, last edit by shelfimage at Nov 1, 2005 11:37:01 AM]
[Nov 1, 2005 11:35:37 AM] Show Printable Version of Post    View Member Profile    Send Private Message    mainewebworks    mainewebworks [Link] Report threatening or abusive post: please login first  Go to top 
Male LSW
Advanced Member
Member's Avatar

USA
Joined: Nov 27, 2003
Post Count: 6285
Status: Offline
Reply to this Post  Reply with Quote 
Re: Javascript needed for Print this page -w/out using onClick=""

Would it not be just as effective to create a Print style sheet ot remove all eye candy and allow th erson to use the print command of the browser?

Maybe I can find something on it at accessify.
[Nov 1, 2005 11:47:26 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male shelfimage
Advanced Member
Member's Avatar

USA
Joined: Mar 24, 2005
Post Count: 3000
Status: Offline
Reply to this Post  Reply with Quote 
Re: Javascript needed for Print this page -w/out using onClick=""

Would it not be just as effective to create a Print style sheet ot remove all eye candy and allow th erson to use the print command of the browser?


I've done that. I have a print.css but, my specs call for a .js print function and the graphic designer has a Print this page graphic.

The page is here: index2.html in the source code it is commented <!-- Print and Email functions -->

I did a bit against spec though: css roll-over for the images instead of js roll-over - haha biggrin

And, the page doesn't validate as 1.0 trans or strict with the onclick="" attribute .... wink

-tia
----------------------------------------
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo
Save the developers<!>
Maine Webworks
----------------------------------------
[Edit 1 times, last edit by shelfimage at Nov 1, 2005 12:00:13 PM]
[Nov 1, 2005 11:58:11 AM] Show Printable Version of Post    View Member Profile    Send Private Message    mainewebworks    mainewebworks [Link] Report threatening or abusive post: please login first  Go to top 
Male tpattison
Advanced Member
Member's Avatar

UK
Joined: Dec 29, 2004
Post Count: 1662
Status: Offline
Reply to this Post  Reply with Quote 
Re: Javascript needed for Print this page -w/out using onClick=""

And, the page doesn't validate as 1.0 trans or strict with the onclick="" attribute ....

Make sure onclick is all lowercase.
----------------------------------------
Pavonis Mons | Listen of the week: "Residue of Desire" by Acumen
[Nov 2, 2005 8:48:07 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male shelfimage
Advanced Member
Member's Avatar

USA
Joined: Mar 24, 2005
Post Count: 3000
Status: Offline
Reply to this Post  Reply with Quote 
Re: Javascript needed for Print this page -w/out using onClick=""

And, the page doesn't validate as 1.0 trans or strict with the onclick="" attribute ....

Make sure onclick is all lowercase.


I didn't even notice angry I had it as onClick="" d oh

Thank-You!!!!

I guess I don't need a different script afterall. It would be neat to have - I think xhthml 1.1 says no .js inline - but I'm not sure if that's in the tag or the header unless it's escaped properly.

-
----------------------------------------
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo
Save the developers<!>
Maine Webworks
[Nov 2, 2005 12:42:41 PM] Show Printable Version of Post    View Member Profile    Send Private Message    mainewebworks    mainewebworks [Link] Report threatening or abusive post: please login first  Go to top 
Male LSW
Advanced Member
Member's Avatar

USA
Joined: Nov 27, 2003
Post Count: 6285
Status: Offline
Reply to this Post  Reply with Quote 
Re: Javascript needed for Print this page -w/out using onClick=""

Just the usual side note... have you tested if the onclick() works using the keypad for navigation? Not everyone uses a mouse... sad
[Nov 2, 2005 12:46:25 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male shelfimage
Advanced Member
Member's Avatar

USA
Joined: Mar 24, 2005
Post Count: 3000
Status: Offline
Reply to this Post  Reply with Quote 
Re: Javascript needed for Print this page -w/out using onClick=""

Just the usual side note... have you tested if the onclick() works using the keypad for navigation? Not everyone uses a mouse... sad

No I didn't.

But, amazingly it works in both ff and ie. Of course I have to tab through about dozen links before I get there. You should see the fangs output. It's ugly.

[ugh]How do you help a graphic designer understand accessiblity and SEO to design templates better?[/ugh]
----------------------------------------
"The art of life lies in a constant readjustment to our surroundings." -Okakura Kakuzo
Save the developers<!>
Maine Webworks
[Nov 2, 2005 1:11:13 PM] Show Printable Version of Post    View Member Profile    Send Private Message    mainewebworks    mainewebworks [Link] Report threatening or abusive post: please login first  Go to top 
Male tpattison
Advanced Member
Member's Avatar

UK
Joined: Dec 29, 2004
Post Count: 1662
Status: Offline
Reply to this Post  Reply with Quote 
Re: Javascript needed for Print this page -w/out using onClick=""

I guess I don't need a different script afterall. It would be neat to have - I think xhthml 1.1 says no .js inline - but I'm not sure if that's in the tag or the header unless it's escaped properly.

I think I've read somewhere that JS events are still accepted in tags, otherwise, how else would you do it? Got me worried now. sad
----------------------------------------
Pavonis Mons | Listen of the week: "Residue of Desire" by Acumen
[Nov 2, 2005 3:05:20 PM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
Male LSW
Advanced Member
Member's Avatar

USA
Joined: Nov 27, 2003
Post Count: 6285
Status: Offline
Reply to this Post  Reply with Quote 
Re: Javascript needed for Print this page -w/out using onClick=""

[ugh]How do you help a graphic designer understand accessiblity and SEO to design templates better?[/ugh]
By asking you all sorts of irritating questions if you tested something or not biggrin

It takes practice and common sense. I was buggered at Accessify for a good year and then one day all the peices began comming together and I began to think accessibility. Just have to read alot. Once stateside I intend to find some local organizations for the blind etc. and hang out with them, maybe get them to test for me.
[Nov 3, 2005 9:05:19 AM] Show Printable Version of Post    View Member Profile    Send Private Message [Link] Report threatening or abusive post: please login first  Go to top 
[ Jump to Last Post ]
Show Printable Version of Thread  Post new Thread