Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call an object with onclick

Status
Not open for further replies.

ChrisRChamberlain

Programmer
Mar 23, 2000
3,392
GB
Hi all

Newbie type question, please be gentle.

Need to convert the following code to call an object to display the .pdf as opposed to showing the .pdf in the window.

Code:
<span title="Click/tap to download vehicle's details" onmouseover="this.style.cursor='pointer';" onclick="window.open('pdfs/6562.pdf','_parent',....</span>

This works in the page

Code:
<div style="width:767px;margin:0 auto;">
[indent]Click on return button to exit[/indent]
[indent]<object width="767" height="1068" data="pdfs/6562.pdf"></object>[/indent]
</div>

TIA

FAQ184-2483​
Chris [pc2]
motrac.co.uk
 
Can you further define the difference between "display the pdf" and "showing the pdf"?
 
spamjim

spamjim said:
Can you further define the difference between "display the pdf" and "showing the pdf"?

Thanks for your reply - my error, both should be the same.

Display is probably more widely used.

FAQ184-2483​
Chris [pc2]
motrac.co.uk
 
You're making this more confusing.

"...to display the .pdf as opposed to showing the .pdf..."

If they should be the same, why do you perceive them to be opposed?
 
spamjim

ChrisRChamberlain said:
my error, both should be the same

IOW, it should have read:-

"Need to convert the following code to call an object in which to display the .pdf as opposed to displaying the .pdf in the window."




FAQ184-2483​
Chris [pc2]
motrac.co.uk
 
I'm assuming you mean "Need to convert the following code to call an object in which to display the .pdf [inline] as opposed to displaying the .pdf in the [parent]window.".

You can either set up a show/hide div visibility toggle and/or play with setAttribute to swap content.


Beware that the inline object display of PDF may not be mobile-friendly, especially with a gaping hole on your page of 767x1068 before the PDF is requested.
 
Found a suitable workaround by using 'onclick="window.open(' to open a new .html file in '_parent'.

Code:
<!DOCTYPE html>
<html>
<body style="background-color:#D6EBEF;">
	<div style="width:100%;margin:0 auto;">
		<h1>Unable to view vehicle's details? <a href="6562.jpg">Tap/click here</a></h1>
		<object width='100%' height='1068' data="6562.pdf"></object>
	</div>
</body>
</html>

The code allows users without a suitable .pdf plugin on their device's browser to view the .pdf as a .jpg instead.

Thanks again to spamjim for your input.

FAQ184-2483​
Chris [pc2]
motrac.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top