use window.opener to change the values from the first page in the second page

I have 2 pages, one is called: "copy06-DEU-08.asp"
and the second one is called "printerfriendly.asp"

The printerfriendly.asp page is a bunch of code that basically makes a copy of the original page and opens it in a new window (even though that page was in a frame to begin with)

The reason this is so useful, is that it works for all the pages in the website and there are about 8 of them (but there will be more soon)...

So if I didn't  have this printerfriendly.asp page, I would have to make copies of each of the pages and link to them, to open them in a new window...

Up until now the copies have been an exact duplicate of the original, but now the client wants the copy to NOT display the "Printer Friendly Version" link.  Only the originals, can have this link!

So I thought I'd use window.opener to get the link's "style.visibility" set to "hidden"

My code in  "copy06-DEU-08.asp" is:
<form name ="mainform" action="printerFriendly.asp" method="post">

<input type="hidden" value = "true" name="hidVar">              

<div style = "visibility:visible" id = "printerDiv"><font color = "blue"><u><a href="/printerFriendly.asp" target = "_blank">Printer-friendly Version:</a></u></font>
</div>
</form>

code in printerfriendly.asp:

<script language="JavaScript">
<!--

if(window.opener.document.mainform.hidVar.value == 'true'){
      document.getElementById("printerDiv").style.visibility = "hidden";
}

// -->
</script>

However, the LINK is not disappearing...
Can you help with this?
What am I doing wrong?
If I can get it to work for this page, then I can get it to work for all the others and create a template for when new pages are created (new pages are created almost every day, so it's very important that I figure out a template)
Gemini532Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

wranlonCommented:
Where does the javascript to set the visibility occur in the printerfriendly page?  You want the script to execute after the printerDiv element has been parsed and is accessible to the DOM, so the script should appear after the element, or in an onload statement.

Or, better yet, why use script at all? Why not use an external style sheet for the print page that hides that element?

Also, do you want to use the visibility:hidden CSS property with the block element, which will result in whitespace, or display:none, which will collapse the whitespace?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ThePlagueCommented:
window.opener.document.getElementById("printerDiv").style.visibility = "hidden";
Gemini532Author Commented:
I don't care if there's empty space left over or not....
I just want the link gone!

However, I'm thinking I should add the entire code for the "printerfriendly.asp" page to make things more clear:
Here is it:
I changed to what ThePlague said: but it didn't work:
window.opener.document.getElementById("printerDiv").style.visibility = "hidden";

<script language="JavaScript">
<!--

if(window.opener.document.mainform.hidVar.value == 'true'){
      window.opener.document.getElementById("printerDiv").style.visibility = "hidden";
}
// -->
</script>
<%@ Language=VBScript %>
<%  Option Explicit   %>
<HTML>
<HEAD>
<TITLE>
Print Friendly Page
</TITLE>
<style>
body {
  color : #000000;
  background : #ffffff;
  font-family : "Times New Roman", Times, serif;
  font-size : 12pt;
}
a {
  text-decoration : underline;
  color : #0000ff;
}
#navigation, #advertising, #other {
  display : none;
}

</style>
</HEAD>
<BODY>
<P>

<%  
      'get the value from the hidden variable in the 06-DEU-08.htm page
      'if Request.Form("hidVar") = "true" then
                  'get the div to become invisible
      '            response.write Request.Form("hidVar")
      'end if




 Const ForReading = 1
 
 Dim strReferrer, objFSO, objOpenFile, strLine
 strReferrer = Request.QueryString("REF")
 
 If Len(strReferrer) < 1 then
    strReferrer = Request.ServerVariables("HTTP_REFERER")
   
    If Len(strReferrer) < 1 then
      Response.Write "An Error occurred!  We could not" & _
        " determine what page you wanted to view the source for..."
      Response.End
    Else
      'With the HTTP_REFERER, the entire URL is passed along... we
      'need to hack out the http://www.4guysfromrolla.com part
      strReferrer = Right(strReferrer,len(strReferrer)-7)
      strReferrer = Right(strReferrer,len(strReferrer) - _
                          instr(1,strReferrer,"/")+1)
    End If
   
  End If

  Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
  Set objOpenFile = objFSO.OpenTextFile(Server.MapPath(strReferrer), _
                                                     ForReading)
 
  'Output each line of the file...
  Do Until objOpenFile.AtEndOfStream
    strLine = objOpenFile.ReadLine
    Response.Write  strLine & vbCrLf
  Loop%>
       <!-- <table width="100%" border="0" cellspacing="0" cellpadding="2">
        <tr>
            <td>&nbsp;</td>
            <td width="90%"><b>This page was printed from:
            <%=Request.ServerVariables("HTTP_REFERER")%></b></td>
        </tr>
      </table>-->
  <%
  objOpenFile.Close
  Set objOpenFile = Nothing
  Set objFSO = Nothing
%>

</BODY>
</HTML>

Expert Spotlight: Joe Anderson (DatabaseMX)

We’ve posted a new Expert Spotlight!  Joe Anderson (DatabaseMX) has been on Experts Exchange since 2006. Learn more about this database architect, guitar aficionado, and Microsoft MVP.

ThePlagueCommented:
got it, use single quotes to set the visibility:

replace:
     window.opener.document.getElementById("printerDiv").style.visibility = "hidden";
with:
     window.opener.document.getElementById("printerDiv").style.visibility = 'hidden';
ThePlagueCommented:
some browsers may complain if the script is located on the top of the page, if you want to make sure it runs everywhere, move the script to  the bottom of the page, after </html>.

let me know.
wranlonCommented:
Standards-wise, the script element should be inside the HEAD or BODY elements.  And, putting the script element at the top like that would fail because the HTML hasn't been loaded yet - there wouldn't be a printerDiv to hide.  Moving the script to the bottom like ThePlague wrote (and I suggested earlier) should fix this.  But, you don't want to hide the opener link, you want to hide the link on the current page, so it should be back to document.getElementById("printerDiv").style.visibility = "hidden";  Single versus double quotes shouldn't matter in this case.
Gemini532Author Commented:
I tried all these suggestions, and so far, it's still not working...
I did a test
alert("test")
 and this wasn't working either...
I"m thinking that the reason is in the code in the "printerfriendly.asp" page ... The code in the "printerfriendly.asp" page, creates a duplicate of my original page, whatever that may be...An EXACT duplicate
So I'm thinking, that the code to eliminate the printer friendly link from the "printerfriendly.asp" page should go with the rest of the code, however that code's in ASP (VB Script)...hmmm...?!?
Any ideas?
Gemini532Author Commented:
I figured out how to do it!  i used CSS
in my original class I did <div class "remLink">
Then in my printerfriendly.asp page, I added the style to make the display equal to NONE, and the link disappeared!   :)
<style>
.remLInk
 display:none
</style>
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Programming

From novice to tech pro — start learning today.