Thomas Evans
Thomas Evans

Reputation: 1

Opening frame content in a new tab

Iam trying to reduce my file sizes by reformatting my site to use the one main index page with an iframe to display the content. However, I want to be able to give my viewers the opportunity to open the contents of the iframe into a new tab to print without printing all of the ads which appear on my index page. I have tried writing a java applet that will identify whatever contents are currently displayed in the iframe and open the file in a new tab with no success. CSS, jquery, javascripts, and php have likewise been of no help in this situation. I do not want to creat two separate links for everything one targeting the iframe and the other targeting a new tab. I want one link that when clicked it will open whatever file is displayed in the frame into a new tab. Am I hoping for too much or is it possible to create such a script?

Upvotes: 0

Views: 920

Answers (3)

Christophe
Christophe

Reputation: 28144

css seems to be the way to go.

You could assign to everything outside the iframe a class "NotForPrint". Then you would use the media attribute and have two different stylesheets on your page, one for media screen and the other for media print. The media print stylesheet would hide all except the iframe. Or you could have a "Print Preview" button, and onclick have a JavaScript function toggle the NotForPrint class display.

The opposite works too, assigning a class of "ForPrint" to the iframe.

In this scenario you don't use a new tab, everything happens in the same window.

Upvotes: 0

Hammo
Hammo

Reputation: 182

Use the target="_parent" attribute on a link within the iFrame.

Upvotes: 0

Peter
Peter

Reputation: 1798

I think you need the target="_blank" attritube in the link, if not, it isn't really clear to me what you mean

Upvotes: 1

Related Questions