?
Solved

Loading .htm page on click of a button foes not work

Posted on 2012-09-05
10
Medium Priority
?
660 Views
Last Modified: 2012-09-06
In my script I have a statement like this..

<button style="background-color: #3399FF; height: 35px; width: 96px; color: #FFFFFF;"
                     onclick="loadDisclaimerPage()">Apply Now</button>

Then in my javascript I have this...
<script type="text/javascript">
        function loadDisclaimerPage()
        {
            window.location = "EmployeeDisclaimer.htm";  
        }

    </script>


I have  the EmployeeDisclaimer.htm clearly visible in my project and it is there. But when I click the "Apply Now" the EmployeeDisclaimer.htm page does not come up.

I have tried on three major browsers (IE8, Firefox and Chrome). Nothing works.
0
Comment
Question by:prain
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 58

Expert Comment

by:Gary
ID: 38370098
Code works fine, so it mustn't be able to find the page
Is it definitely in the same folder as the calling page
0
 

Author Comment

by:prain
ID: 38370112
Yes sir. I can see it, I can run it independently. Just that the button click does not bring it up.
0
 
LVL 58

Expert Comment

by:Gary
ID: 38370143
Do you have a url to the page, add an alert into the function to see if it is being fired.
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 12

Expert Comment

by:rajapandian_81
ID: 38371611
Hi,

Try adding "return false;" after the function call. Also try window.location.href instead of window.location.
<button style="background-color: #3399FF; height: 35px; width: 96px; color: #FFFFFF;" onclick="loadDisclaimerPage(); return false;">Apply Now</button>

<script type="text/javascript">
        function loadDisclaimerPage() 
        {
            window.location.href = "EmployeeDisclaimer.htm";  
        }

    </script>

Open in new window

0
 
LVL 7

Expert Comment

by:dimmergeek
ID: 38371953
If you're going to use this function for multiple redirects, that's fine.
If this is a once and done thing, why not just use a link:

button style="background-color: #3399FF; height: 35px; width: 96px; color: #FFFFFF;" self.location=EmployeeDisclaimer.htm'">Apply Now</button>

Open in new window

0
 

Author Comment

by:prain
ID: 38372067
GaryC123 : Yes the message box pops up when I put an alert().
Rajapandian81 : I tried .ref also. Still the same problem.
dimmergeek: I tried your suggestion. Problem still exists.

I am not sure if this is something restricted by this machine. I tend to belive that because this does not work in any of the browsers I have tested (IE, FF and Chrome) I have other links with pdf files etc that display on button clicks and they work great.

-prain
0
 
LVL 12

Accepted Solution

by:
rajapandian_81 earned 600 total points
ID: 38372089
Have you tried after adding "return false;" in onclick event of button as shown in my previous comment.
0
 

Author Comment

by:prain
ID: 38372142
rajapandian_81,

SUPER!. It worked. So can you please explain what the deal here? Why it is expecting a return false?
0
 
LVL 12

Expert Comment

by:rajapandian_81
ID: 38372356
0
 

Author Closing Comment

by:prain
ID: 38372466
Thanks.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
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)
Suggested Courses

850 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