G Gr
G Gr

Reputation: 6080

HTML button redirect error

So I have been working with the BootMetro framework and I came across a problem trying to create links on the icon buttons.

Part of the main header bar I created extra icons. However I cant seem to figure out how to turn the buttons into redirectable links:

        <div class="top-info-block">
           <b class="icon-blogger-2" onclick="window.location.href='www.blogger.com'"></b>
           <b class="icon-facebook-2"></b>
           <b class="icon-google-plus-3"></b>
           <b class="icon-youtube"></b>
        </div>

When using VS2012 I get a page not found error as the html link comes out as: http://localhost:8581/www.blogger.com is this just something with VS2012 or is my onclick method wrong?

Upvotes: 1

Views: 229

Answers (1)

couzzi
couzzi

Reputation: 6366

change onclick="window.location.href='www.blogger.com'" to onclick="window.location.href='http://www.blogger.com'"

Without the protocol (http), the window.location.href is trying to resolve www.blogger.com as a file/directory/ that is relative to your current location. In this case, http://localhost:8581/.

Hope that helps.

Upvotes: 5

Related Questions