0

So I use the following code to create a TabContainer with 3 tabs. However, when I print the page, I would like the page to look as if there is no call to dojotype="dijit.layout.TabContainer". What should I do to achieve this?

<div id="holdtabscript">
<script type="text/javascript">
dojo.require("dijit.layout.TabContainer");
dojo.require("dijit.layout.ContentPane");
</script>
</div>

<div dojotype="dijit.layout.TabContainer" id="tabfunct">
<div dojotype="dijit.layout.ContentPane" title="pane1" selected="selected"> content1</div>
<div dojotype="dijit.layout.ContentPane" title="pane2"> content2</div>
<div dojotype="dijit.layout.ContentPane" title="pane3"> contents</div>
</div>
user110
  • 315
  • 1
  • 11
  • looks like you should read this: http://stackoverflow.com/questions/4927025/can-jquery-modify-the-css-for-a-specific-media-type – GnrlBzik Mar 08 '12 at 19:37

3 Answers3

2

I'd recommend using CSS to do it, if you have access to the page content. Include a print stylesheet that hides the div...

In the head...

<link rel="stylesheet" tyle="text/css" media="print" href="print-stylesheet.css">

The css...

#tabfunct { display: none; }

Much easier than using javascript for something like this.

Reinstate Monica Cellio
  • 25,975
  • 6
  • 51
  • 67
0
<style type="text/css">
    @media print {
      #tabfunct  { display:none }
    }
</style>
powtac
  • 40,542
  • 28
  • 115
  • 170
  • I'm not trying to hide the div, but trying to remove the attr dojotype="dijit.layout.TabContainer" of that div. – user110 Mar 08 '12 at 19:39
  • Thanks @powtac - I've not seen that method before. I've only used the one I posted. Yours is much nicer for small changes. (I'm not gonna vote it up though, because the poster has asked the wrong question so both our answers are actually wrong!) – Reinstate Monica Cellio Mar 08 '12 at 19:40
0

You could use the following library: http://cssmedia.pemor.pl/

Then just:

$(function() {
   if(IsMediaType('print') > 0) {
      $('#tabfunct').removeAttr('dojotype');
   }
});

Should probably do the trick.

Leonard Garvey
  • 1,517
  • 12
  • 8