Jump to content

Obtrusive Alert


mikePhp

Recommended Posts

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

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.