mikePhp Posted September 4, 2008 Share Posted September 4, 2008 Hiya Guys, I have been making a TINY WEENY script to notify(alert) Clients that when the lick the link (which opens a PDF in the browser) to please be patient whilst the PDF loads on the browser. Here it is...? newWindow = { init:function() { if(!document.getElementsByTagName) { return; } var webLink = document.getElementsByTagName('a'); if(!webLink) { return; } for(var i=0; i<webLink.length; i++) { if(webLink[i].getAttribute('id').toLowerCase().match('alert')) { webLink[i].onclick = function() { alert('Please be patient whilst the PDF loads on your browser'); return true; } } } } } Now my query is, When I Load this in IE 7, I have no Problems the PDF loads in the browser FINE, But when I check this in Safari (mac), Safari (win), Firefox(mac), Firefox (win), Opera(mac), Opera(win) I have no success, it Bypasses the script and just loads the PDF into the Browser..? If someone could help me with this that would be great, Also If you I could have help in getting it to open a new window and load the PDF into that so users can see that its actually loading, as Vista makes it look like nothing is. If i tried this, Would this work..? newWindow = { init:function() { if(!document.getElementsByTagName) { return; } var webLink = document.getElementsByTagName('a'); if(!webLink) { return; } for(var i=0; i<webLink.length; i++) { if(webLink[i].className.match('openUp')) { webLink[i].onclick = function() { window.open(this.getAttribute('href'),'newWindow'); return false; } } } for(var i=0; i<webLink.length; i++) { if(webLink[i].getAttribute('id').toLowerCase().match('alert')) { webLink[i].onclick = function() { alert('Please be patient whilst the PDF loads on your browser'); return false; window.open(this.getAttribute('href'),'PDFVIEW'); } } } } } Thanks Again the link: http://www.planet-group.net/mediapack Quote Link to comment Share on other sites More sharing options...
lemmin Posted September 4, 2008 Share Posted September 4, 2008 Try this: <a href="file.pdf" target="_blank" onclick="alert('Please be patient whilst loading');">PDF Link</a> Quote Link to comment Share on other sites More sharing options...
mikePhp Posted September 4, 2008 Author Share Posted September 4, 2008 Try this: <a href="file.pdf" target="_blank" onclick="alert('Please be patient whilst loading');">PDF Link</a> thanks for that matey I know of that way and was going to put it in, but i find it abit tacky and bad practice/bad coding to write with in the HTML like that. or is this the only way? thanks again mike Quote Link to comment Share on other sites More sharing options...
lemmin Posted September 4, 2008 Share Posted September 4, 2008 It certainly isn't the only way, but why would you want to have more code for the user to download when you can write it inline? I don't know why it would be considered bad practice. What exactly are you trying to avoid doing? Quote Link to comment Share on other sites More sharing options...
mikePhp Posted September 5, 2008 Author Share Posted September 5, 2008 It certainly isn't the only way, but why would you want to have more code for the user to download when you can write it inline? I don't know why it would be considered bad practice. What exactly are you trying to avoid doing? No No, it wasn't the fact if that, I have just always been taught to try an avoid inline coding in HTML, and always have a File which Holds most it not all of the Javascript, It also makes it easier to edit. N e ways i will dop what you have wrote for the time being until i manage to find out the way i am asking for.. Thanks again lemmin Mike Quote Link to comment Share on other sites More sharing options...
mikePhp Posted September 5, 2008 Author Share Posted September 5, 2008 Its Ok, I cHanged the the ID to a class and used it that way with window.open aswell Thanks again Mike Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.