JavaScrip popup box with OK option only

Hi JavaScript experts,

I have a html page which has a hyperlink to open the pps (powerpoint file). It takes quite some times to load the pps,  I want to pop up a warning messagebox with "OK"  when user clicks hyperlink. then when user click "ok" it will kick off hyperlink to load the pps.
Please advise. Thanks
LuckyColdAsked:
Who is Participating?
 
ncooCommented:
Not everyone has javascript, mobile browser, accessibility browsers. There should always be an alternative just incase, that alternative could result in someone finding what they're looking for and making a purchase or using the site for longer more ad revenue.
0
 
PhatzerCommented:
I'd suggest a javascript confirmation message. This is how you would use it...

Put this in the <head> section of your web page:
<script language="JavaScript">
<!--

function ppWarning() {
  if (confirm("This file can take a long time to load. Are you sure you wish to continue?")) {
    window.location='POWERPOINTFILE';
  }
}

//-->
</script>

How to use in hyperlinks on the page:
<a href="#" onClick="javascript:ppWarning();">Open PPT File</a>

That will give an OK/Cancel confirmation box and if they click OK, it will take them to the PPT file. You will need to change the POWERPOINTFILE that I typed to the actual file URL of course.
0
 
Russell2566Commented:
<script>
      function loadSlowUrl(url) {
            alert("The Link You Have Clicked On My Load Slow");
            window.location.href = url;
      }
</script>

<a href="JavaScript: loadSlowUrl('http://www.google.com');">Go Someplace</a>
0
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
ncooCommented:
The solutions above will not work if the user does not have javascript.

The following will show the confirm download option if javascript is supported if the user does not have javascript they can still download the file.

Not everyone has Javascript or has it turned on, so it is important to give the option.

<html>
<head>
<script type="text/javascript">
<!--

function confirmPP(url) {
      if (confirm("This file is quite large and will take time to download. Do you want to continue?")) {
            window.location.href = url;
      }
}

//-->
</script>
</head>
<body>


<a href="http://google.com" onclick="javascript:confirmPP(this.href);return false;">Open Powerpoint File</a>

</body>

</html>
0
 
ncooCommented:
The problem with using an alert is the user is forced to download the file even if they don't want to the confirm gives the user an option.

So the use of a confirm is most appropriate here.

But should you want to use the alert the code is below use the second link:

<html>
<head>
<script type="text/javascript">
<!--

function confirmPP(url) {
      if (confirm("This file is quite large and will take time to download. Do you want to continue?")) {
            window.location.href = url;
      }
}

function alertPP(url) {
      alert("This file is quite large and will take time to download. Do you want to continue?");
      window.location.href = url;
}
//-->
</script>
</head>
<body>


<a href="http://google.com" onclick="javascript:confirmPP(this.href);return false;">Confirm Open Powerpoint File</a><br/>
<a href="http://google.com" onclick="javascript:alertPP(this.href);return false;">Alert Open Powerpoint File</a>

</body>

</html>
0
 
Russell2566Commented:
my alert box ws just giving the user exactly what he wanted.... and who doesn't have JavaScript enabled anymore :)
0
 
LuckyColdAuthor Commented:
Thanks everyone for the quick response.
I am testing it with all your suggestions. I let you how it goes tomorrow.

Thanks again.
0
 
LuckyColdAuthor Commented:
All your answers are working. I 'll split the points.
Thanks phatzer, russell2566 and ncoo.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.