/    Sign up×
Community /Pin to ProfileBookmark

Image to print feature

Hello everyone,

Pretty basic question, but I’m unable to answer it – so here goes. I would like to place an image on my web site so when a user clicks on it, it opens up in a new box/window and the print screen box also comes on.

The best example I can give is when you go to Google maps, and click on the print button once you have your map, it opens up the map in a smaller box and your print box comes up to print that specific portion of the map.

Do any of you know a quick way to do this. I primarily use plain HTML, CSS, and very few javascripts. I can create the popup portion just fine. I just want to find out how to make the print box open up when it opens the image.

Thanks,
jj

to post a comment
HTML

4 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisNov 08.2007 — <a href="theimageurl" onclick="popup=window.open(this.href,'','');popup.onload=window.print();return false"><img src=...></a>
Copy linkTweet thisAlerts:
@jjbarnoneauthorNov 08.2007 — I can't seem to get that to work?

in my header section I have this for a popup feature...it basically works if the person has javascript turned off - a blank window opens and sends the visitor to the intended path...


<script type="text/javascript">

<!--

function myOpenWindow(winURL, winName, winFeatures, winObj)

{

var theWin;

if (winObj != null)

{

if (!winObj.closed)

{

winObj.focus();

return winObj;

}

}

theWin = window.open(winURL, winName, winFeatures);

return theWin;

}

var myWin = null;

//-->

</script>



and then in the HTML section, I have this for the link attributes:



<a href="test.html" target="_blank" onclick="myOpenWindow(this,'Window Name','height=400,width=750,scrollbars=no');onload=window.print();return false">Image goes here</a>

There are different variations, the major one is that the popup box does not load until you close the print box?

Another variation is that the print box comes up but the popup disappears (goes to the background behind the original page) and the print box is created for the original page which it will print, not the popup box? I tried different variations like popup.onload=window.print(), pop.onload=window.print(), window.onload=window.print() - but nothing seems to work. Do I need to focus the popup box?
Copy linkTweet thisAlerts:
@gil_davisNov 09.2007 — That is what happens when you don't post code in the first place. ;-)
<i>
</i>function myOpenWindow(winURL, winName, winFeatures, winObj) {
var theWin;
if (winObj != null)
{if (!winObj.closed)
{winObj.focus();[color=red]
winObj.onload = window.print();[/color]
return winObj;}
}
theWin = window.open(winURL, winName, winFeatures);[color=red]
theWin.onload = window.print();[/color]
return theWin;
}
Copy linkTweet thisAlerts:
@jjbarnoneauthorNov 11.2007 — I slipped that in there and it works....had to put a settimeout feature for a second to prevent it from loading the thing too soon. Thanks for the help...
×

Success!

Help @jjbarnone spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.5,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...