views:

50

answers:

2

Alright, now I am downright bewildered on what is happening. I am creating a safari extension called unibar(which is a separate toolbar extension, not a toolbar item), a clone of Chrome's address bar. what I want so far is to at least create a regular address bar, and build from there. Here is my bar.html file, which is connected to the toolbar.

<html>
<head>
    <title>Unibar</title>

    <script type="text/javascript">
    function openInTab(source){
        safari.application.activeBrowserWindow.activeTab.url=source;
        }
    </script>

</head>
<body>
<form name="form" onsubmit="javascript:openInTab(server+'safari/');">
<input type="text" name="textfield" />
</form>
</body>
</html>

When I hit enter after I have typed in my address, IT BRINGS UP BAR.HTML IN THE BROWSER WINDOW!!!! What is happening?!?

A: 

Remove javascript: and add return false;.

SLaks
Sorry, but this still does the same thing.
Flafla2
A: 

Ah! I have found the answer. I idiotically forgot to declare what "server" is in the code. Here is my new code.

<html>
<head>
    <title>Unibar</title>

    <script type="text/javascript">
    function openInTab(source){
        safari.application.activeBrowserWindow.activeTab.url=source;
        }
    </script>

</head>
<body>
<form name="form">
<input type="text" name="textfield" />
<input type="button" value="Go!" onclick="javascript:openInTab(document.form.textfield.value);" />
</form>
</body>
</html>
Flafla2