Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

Serious Coding question about javascript


  • Please log in to reply

#1
Caboose96z

Caboose96z

    New Member

  • Member
  • Pip
  • 3 posts
Okay, I have come up with a piece of code that will allow you to print part of a webpage and not the whole thing. It uses the <div></div> codes and <id> tags to get this done. However, I am having issues getting it to work in Firefox or Netscape. It does work like a charm in IE. Anythoughts on how I can get this done?

Here is the code:

<style type="text/css">
<!--
@media print{
.noprn{
display:none;
visibility:hidden;
}
.prn{
left:0px;
top:0px;
display:block;
visibility:visible;
}
}
-->
</style>
<script language="JavaScript" type="text/javascript">
<!--
function printDiv (id) {
var divs = document.getElementsByTagName('DIV');
for (var d = 0; d < divs.length; d++){
divs[d].className='noprn';
}
document.getElementById(id).className='prn';
window.print();
}
//-->
</script>


<input name="Print" type="button" onClick="printDiv(this.form.divSelect.value); history.go(0)" value="Print" />


Here is the website that I am using it on:

http://jobs.georgiasouthern.edu

on the employment/professional-admin and classified page.

also, a forum I built http://www.cgfyb.com/ if you would like to review and make some suggestions!

Thanks in advance

Jamey Bland

Edited by Caboose96z, 23 June 2005 - 10:34 AM.

  • 0

Advertisements


#2
remintellegere

remintellegere

    Member

  • Member
  • PipPip
  • 34 posts
I'm not an expert in Javascript so I won't try and tell you what the right code is. I will help you with why the code isn't working.

Netscape and IE run two different scripting languages. Javascript was written BY Netscape and is used by Netscape like browsers. JScript, is Microsoft's counterpart.

To learn more about the differences, check Microsoft's MSDN. It should have information on the differences and why yours isn't working.
  • 0

#3
ssone

ssone

    Member

  • Member
  • PipPipPip
  • 301 posts
is this webpage on the web or on ur comp? I can see if there is a way to work it out using some other techniques.
  • 0

#4
memetdo

memetdo

    New Member

  • Member
  • Pip
  • 1 posts
Hi,


<input name="Print" type="button" onClick="printDiv(this.form.divSelect.value); history.go(0)" value="Print" />

You should try "this.parent.divSelect.value" instead of one you used.

I hope that it works.
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP