> > > what is correct way open a PDF document in new window use hyperlink? I
> > > want show images thumbnails linked with PDF files, when click on
[quoted text clipped - 43 lines]
> if (!document.getElementsByTagName) return false;
> var links = document.getElementsByTagName("a");
The document has a links collection, there is no need for
getElementsByTagName:
var links = document.links;
<URL: http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-7068919 >
> for (var i=0; i < links.length; i++) {
> if (links[i].href.indexOf('.pdf') !== -1) {
> links[i].onclick =
> function() {
> window.open(this.href,'popper','resizable,scrollbars');
A better strategy is to keep a reference to the window and re-use it
if it's been opened previously and is still open - it helps to prevent
multiple pop-ups.
> return false;
> }
> }
> }
It would be a good idea at this point to prevent circular references:
links = null;
> }
>
[quoted text clipped - 10 lines]
> script is useless at all.
> Is there normal stable solution?
No. Browsers are configured by users to deal with pop-ups according
to the users' wishes. Browsers will also deal with files like PDFs
differently - mine will open them in a different application and will
not open a popup.
--
Rob
mistral - 09 Jul 2008 23:35 GMT
> > > > what is correct way open a PDF document in new window use hyperlink? I
> > > > want show images thumbnails linked with PDF files, when click on
[quoted text clipped - 92 lines]
> --
> Rob
----------------
Just tried this version, no any difference, works the same:
// Opens PDF links in new windows
function doPopups()
{
if (!document.getElementsByTagName) return false;
var links = document.links;
for (var i=0; i < links.length; i++) {
if (links[i].href.indexOf('.pdf') !== -1) {
links[i].onclick =
function() {
window.open(this.href,'popper','resizable,scrollbars');
return false;
}
}
}
links = null;
}
Probably, no needs in javascript at all, since target="_blank" in href
statement do this.
<a href="http://website.uk.com/downloads/manual.pdf"
target="_blank">TX handbook</a>
Perhaps use FRAME-based page have more sence.
mistral - 10 Jul 2008 15:05 GMT
> > > > > what is correct way open a PDF document in new window use hyperlink? I
> > > > > want show images thumbnails linked with PDF files, when click on
[quoted text clipped - 123 lines]
>
> Perhaps use FRAME-based page have more sence.
---
Any ideas?
Thomas 'PointedEars' Lahn - 13 Jul 2008 22:10 GMT
>> if (!document.getElementsByTagName) return false;
>> var links = document.getElementsByTagName("a");
[quoted text clipped - 5 lines]
>
> <URL: http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-7068919 >
If you read this more thoroughly, you will observe that there may be a need
to use HTMLDocument::getElementsByTagName("a"). The feature test performed
for it here, however, is inadequate.
PointedEars

Signature
Use any version of Microsoft Frontpage to create your site.
(This won't prevent people from viewing your source, but no one
will want to steal it.)
-- from <http://www.vortex-webdesign.com/help/hidesource.htm>