开发者

Radio Button for page Selection Using JavaScript

开发者 https://www.devze.com 2023-03-06 15:14 出处:网络
I\'m Learning Please Help. I Appreciate an开发者_如何学编程y replys I would like to to know how to make an alert message where it ask the user to select one page and once it selected load into that p

I'm Learning Please Help. I Appreciate an开发者_如何学编程y replys

I would like to to know how to make an alert message where it ask the user to select one page and once it selected load into that particular page.

for example i would like to have

Home page - index.html

About Us - about.html

Contact Us -contact.html


Just use HTML links, no script necessary:

<a href="index.html">Home page</a>

Using any kind of popup for genearl navigation is just plain annoying.

To do what you are asking, learn how to create an element (say a div) with the links as content, then display or hide it depending on some user action. You may also want to position it in the page and have it cover other content, but they are just further annoyances.


Here's a start for you:

<script type="text/javascript">
    function changePage(pageNum) {
        if (pageNum == 1) { var pageURL = 'page1.html'; }
        if (pageNum == 2) { var pageURL = 'page2.html'; }
        if (pageNum == 3) { var pageURL = 'page3.html'; }
        window.location.href = pageURL;
    }
</script>

<h1>Select Page:</h1>
<input type="button" onclick="changePage(1);" value="Page 1">
<input type="button" onclick="changePage(2);" value="Page 2">
<input type="button" onclick="changePage(3);" value="Page 3">
0

精彩评论

暂无评论...
验证码 换一张
取 消