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

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.
prainAsked:
Who is Participating?
 
rajapandian_81Commented:
Have you tried after adding "return false;" in onclick event of button as shown in my previous comment.
0
 
GaryCommented:
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
 
prainAuthor Commented:
Yes sir. I can see it, I can run it independently. Just that the button click does not bring it up.
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
GaryCommented:
Do you have a url to the page, add an alert into the function to see if it is being fired.
0
 
rajapandian_81Commented:
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
 
dimmergeekCommented:
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
 
prainAuthor Commented:
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
 
prainAuthor Commented:
rajapandian_81,

SUPER!. It worked. So can you please explain what the deal here? Why it is expecting a return false?
0
 
rajapandian_81Commented:
0
 
prainAuthor Commented:
Thanks.
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.