Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
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