my dog learned polymorphism*
The moose likes HTML, CSS and JavaScript and the fly likes if link is clicked Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "if link is clicked" Watch "if link is clicked" New topic
Author

if link is clicked

samuel marin
Greenhorn

Joined: Nov 18, 2011
Posts: 16
How can I do something like show an embed document if a link is press.

The logic would be something like:




Being The link something like:



Thanks much
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30123
    
150

Samuel,
You'll need a JavaScript even handler to recognize the link was clicked.

One way is to hard code it:


The other way is to use a library like jQuery
see example. As your apps grow, it becomes more useful to not have JavaScript all over your codebase.

Either way, you then implement the JavaScript function to show the embedded content. You could even load it in a hidden div on page load and show it when that function is called.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Arun Giridhar
Ranch Hand

Joined: Mar 10, 2012
Posts: 145

You can use Jquery but i'm pretty much sure all browsers can handle document.getElementById() even IE 5.5 .


hate Professionalism
samuel marin
Greenhorn

Joined: Nov 18, 2011
Posts: 16
Ok,

I have the following:

<p>Link</p>

<script>
$("p").click(function () {
$(this).showembed();
});
</script>


Now, how can I do to tell when I press "Link" show the following document. "document.pdf"

Something like:

<p (\document.pdf)>Link</p>

<script>
var document
$("p").click(function () {
$(this).showembed(document,);
});
</script>

So when I press the "Link" the document.pdf shows embed

Thanks so much
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60782
    
  65

You can't embed a PDF inside an HTML document. So you'll either need to show it in the whole window, open a new window to show it, or embed an iframe element in which to show the PDF.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: if link is clicked
 
Similar Threads
get mac addresss of client system
Pictures
java code to extract EMBED pdf from doc file
Java calling perl
How to embed file objects injava using POI