Results 1 to 7 of 7

Thread: onclick=location.href (new window)

  1. #1
    Join Date
    Mar 2010
    Posts
    36

    onclick=location.href (new window)

    I am trying to write a code through which I can open a new window using href and still keep onclick=location.href as displayed in the code following ? I don't need to use the html <a> construct like <a href="contact.asp">Contact Webmaster</a> probably because I don't want the hand pointer and URL appearing in the status bar.

    <td width="34%" align="center">
    <img name="help" border="0" src="images/help.gif" onclick=location.href="help.htm"
    onmouseover="roll('help','images/help_mouseover.gif')"
    onmouseout="roll('help','images/help.gif')"
    onmousedown="roll('help','images/help_mouseclick.gif')"
    onmouseup="roll('help','images/help_mouseover.gif')"><br></td>

  2. #2
    Join Date
    May 2008
    Posts
    2,389

    onclick=location.href (new window)

    Hi Raja,

    I am sorry but didn't see the statusbar part but according to your issues with the implementation I have something for you that can be helpful for you and I am sure you need to use this ...

    Code:
    onclick="window.open('help.htm','name','height=200,width=200')"
    or do you mean you desired to keep the same code:location.href="help.htm". If you provide some more clear information then I can be able to help more ..

  3. #3
    Join Date
    Dec 2009
    Posts
    292

    Onclick to open a new window

    I have created a button an that gets clicked will popup an alert box and then it redirects to the user on a new website. But the issue is, I want to open the external site in a new window like target="_blank" but I am unable to get it to do that; it opens the site in the current window.

    <input name="button" type="button" class="extsite" target="_blank" onClick="parent.location='http://www.Techarena.in'; alert('We are redirecting you to an external site')" Value="Click to visit the site.">

    I tried to make this as a regular anchor link but then the Google Toolbar kept blocking the new window as a popup. I have googled a lot for the perfect solution with no luck. I think , I have to make some type of javascript function to manage it ?

    Thanks.
    Last edited by Miles Runner; 10-05-2010 at 04:44 PM.

  4. #4
    Join Date
    Feb 2008
    Posts
    1,852

    Onclick to open a new window

    The 'target' attribute that you have configured is not valid on an <input> element. The target attribute on an anchor (<a>) suggest that the target of the href attribute. You should be able to do what you are after with a regular anchor....

    <a href="http://www.Techarena.in" onclick="alert('We are sending you to an external site');window.open('http://www.techarena.in','external');return false;" title="Opens the external website in a new window">Click to visit the site</a>

    It will at least activate your users to catch to the external site if they have JS disabled (albeit in the similar window). If the Google Toolbar is blocking it, then I recon it is going to block every popup - although you can try dealing rid of the alert('We are...'); ...? The window.open() function can accept a 3rd parameter that controls the size and gadgets that displays on the popup window, by default it will be just another window with everything. Popup blockers should not (by default) block popups that are a result of a direct user action, such as clicking on a link.

    Using a JavaScript function will not be helpful for you in this respect, other than creating your code a much more tidy.
    Last edited by MindSpace; 10-05-2010 at 04:42 PM.

  5. #5
    Join Date
    Dec 2009
    Posts
    292

    Onclick to open a new window

    Thanks for the your support and help. I desired it to be in a button form but changed it to a easy link instead and still have the alert and opening in a new window that was much necessary .

    Code:
    <a href="http://www.Techarena.in" target="_blank" class="ext" onclick="alert('External site')";>CLICK TO Visit External site</a>

    And one more thing, I want discuss here is that the following code is working in Firefox but IE7 still blocks with Googlebar. I got this to work though:

    <a class="activate" target="_blank" href="javascript:alert('Alert text');location.href='http://www.Techarena.in'">Click</a>

    Its doesn't work if Javascript is disabled though.The code you suggest that it still gets blocked by the toolbar but thanks anyway.
    Last edited by Miles Runner; 10-05-2010 at 04:48 PM.

  6. #6
    Join Date
    Nov 2005
    Posts
    3,026

    Re: onclick=location.href (new window)

    Hi miles , you told that It assumes as if you have found a method to get around Google bar's popup blocker (within IE7)? But I am a bit surprised that few of the ways suggested here, fail (as if the 'blocker' setting is configured particularly high), and yours does not get blocked?! Almost suggesting the popup blocker itself is at fault?!

    Particularly, I only use the default popup blockers (on their default configurations) that come as section of FF and IE and have no issues with displaying properly coded popups, and nor am I overrun with disgusting popups. I am so curious, does the following get blocked by your 'Google bar popup blocker' under IE7...?

    Code:
    <a href="http://www.logiprism.com" onclick="window.open('http://www.Techarena.in','popup');return false;">Click here to popup</a>

  7. #7
    Join Date
    Dec 2009
    Posts
    292

    Re: onclick=location.href (new window)

    No way, that does not get blocked by the toolbar. It should be the pop-up alert box which is triggering the blocker. And now I have added it


    <script language="JavaScript">
    function LinkAlert ()
    {
    alert ("You are going to redirected from this site");
    }
    </script>

    And added LinkAlert to it:

    <a href="http://www.Techarena.in" onclick="window.open('http://www.Techarena.in','popup');LinkAlert();return false;" >Click here to popup</a>

    And that works,but if in case, I placed the Link Alert before the window.open, Google blocks it.

Similar Threads

  1. IE7 href + onclick - both happen
    By Ucchal in forum Software Development
    Replies: 5
    Last Post: 24-05-2010, 03:58 PM
  2. Replies: 6
    Last Post: 18-05-2010, 12:27 AM
  3. Dynamic HREF on onClick
    By hounds in forum Software Development
    Replies: 6
    Last Post: 13-05-2010, 11:53 PM
  4. A Href And OnClick Button
    By Endowed in forum Software Development
    Replies: 5
    Last Post: 11-05-2010, 10:24 PM
  5. <A HREF="#" onClick="window.open ('sitename.html') ...>
    By Amy Adams in forum Software Development
    Replies: 4
    Last Post: 11-05-2010, 12:45 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,750,718,737.05641 seconds with 16 queries