?
Solved

JavaScrip popup box with OK option only

Posted on 2007-10-04
8
Medium Priority
?
602 Views
Last Modified: 2011-10-03
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
0
Comment
Question by:LuckyCold
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 10

Assisted Solution

by:Phatzer
Phatzer earned 400 total points
ID: 20015811
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
 
LVL 4

Expert Comment

by:Russell2566
ID: 20015878
<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
 
LVL 15

Expert Comment

by:ncoo
ID: 20015956
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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 15

Expert Comment

by:ncoo
ID: 20015977
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
 
LVL 4

Assisted Solution

by:Russell2566
Russell2566 earned 400 total points
ID: 20016025
my alert box ws just giving the user exactly what he wanted.... and who doesn't have JavaScript enabled anymore :)
0
 
LVL 15

Accepted Solution

by:
ncoo earned 1200 total points
ID: 20016227
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
 

Author Comment

by:LuckyCold
ID: 20016512
Thanks everyone for the quick response.
I am testing it with all your suggestions. I let you how it goes tomorrow.

Thanks again.
0
 

Author Comment

by:LuckyCold
ID: 20017948
All your answers are working. I 'll split the points.
Thanks phatzer, russell2566 and ncoo.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question