hey guys trying something new using script here is what i got i have a button and i want it to do is go to another html page i have created. here is what i got. i have set up in script.

<html>
<body>
<script type="text/javascript">
    function getSite()
    [

    ]
</script>


<button type="button"onclick="getSite()">Register</button>

am i close? what so i put in the function to do this?

Dani AI

Generated

Good call, — using JavaScript to navigate works, but there are better patterns to know so the page behaves reliably and accessibly years later.

Use a plain link as the primary control when the intent is navigation: browsers and assistive tech treat anchors correctly, users can open them in a new tab, and they work with JavaScript disabled. See the HTML anchor element docs for details: Anchor element (MDN)

If you need to keep a button look but still navigate, attach an event listener and use the Location API instead of inline handlers or popup opener calls. Example of unobtrusive JS (same-tab navigation):

<button id="register">Register</button>

<script>
document.getElementById('register').addEventListener('click', function () {
  location.assign('register.html'); // preserves history
});
</script>

Use location.replace() if you want to replace history. For opening a new tab, prefer a link with target="_blank" plus rel="noopener noreferrer" to avoid window.opener risks (or see the Window.open docs if you must open programmatically): Window.open (MDN) and Location.assign (MDN)

Small fixes to the original snippet: JavaScript functions use curly braces {} (not []), avoid inline onclick for maintainability, and ensure buttons inside forms have type="button" when not submitting.

i got it just add window.open(" and whatever .com")

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.