html - Javascript - opening a link - Stack Overflow

My Javascript isnt up to scratch, and im having problems making the link open in the same window rather

My Javascript isnt up to scratch, and im having problems making the link open in the same window rather than a new popup.

In my html I have the following link

<a href="javascript:go_registerParamList('<%=appendStr%>');">Open An Account</a>

The Javascript for the 'go_registerParamList' is:

function go_registerParamList(paramList) {
    if (self.opener == null) {
        var base_window = self;
    } else {
        var base_window = self.opener;
    }
    if (paramList == '') {
        var link = 'https://${accountUrl}?action=go_register_popup&area=SK&button=openregbutton&promo=new_regbutton_en&crea=img&bus_channel=SK';
    } else {
        var link = 'https://${accountUrl}?action=go_register_popup&area=SK&button=openregbutton&promo=new_regbutton_en&crea=img' + '&' + paramList;
    }

    base_window.open(link, "pp_registration", "width=642, height=620, scrollbars=no,  menubar=no, status=no, scrollbars=no, resizable=yes,screenX=5, screenY=5, left=5, top=5");
}

Thanks in advance.

My Javascript isnt up to scratch, and im having problems making the link open in the same window rather than a new popup.

In my html I have the following link

<a href="javascript:go_registerParamList('<%=appendStr%>');">Open An Account</a>

The Javascript for the 'go_registerParamList' is:

function go_registerParamList(paramList) {
    if (self.opener == null) {
        var base_window = self;
    } else {
        var base_window = self.opener;
    }
    if (paramList == '') {
        var link = 'https://${accountUrl}?action=go_register_popup&area=SK&button=openregbutton&promo=new_regbutton_en&crea=img&bus_channel=SK';
    } else {
        var link = 'https://${accountUrl}?action=go_register_popup&area=SK&button=openregbutton&promo=new_regbutton_en&crea=img' + '&' + paramList;
    }

    base_window.open(link, "pp_registration", "width=642, height=620, scrollbars=no,  menubar=no, status=no, scrollbars=no, resizable=yes,screenX=5, screenY=5, left=5, top=5");
}

Thanks in advance.

Share Improve this question edited Apr 20, 2012 at 10:20 Milap 7,2298 gold badges27 silver badges47 bronze badges asked Apr 19, 2012 at 10:52 BeccaBecca 111 gold badge1 silver badge2 bronze badges 1
  • possible duplicate of stackoverflow./questions/267704/… – TRR Commented Apr 19, 2012 at 10:55
Add a ment  | 

5 Answers 5

Reset to default 2

JavaScript function :

function openInSameWindow(evt) {
    window.location=evt;
}

HTML hyperlink to open in same window :

<a onclick="openInSameWindow('http://google.')">Click to open in same window</a>

You can call the function openInSameWindow to open a link in same window.

The .open() method opens a new window.

Instead, you can just do:

window.location = link;

So:

function go_registerParamList(paramList)
{
    var link;
    if(paramList == '')
    {
        link = 'https://${accountUrl}?action=go_register_popup&area=SK&button=openregbutton&promo=new_regbutton_en&crea=img&bus_channel=SK';
    }
    else
    {
        link = 'https://${accountUrl}?action=go_register_popup&area=SK&button=openregbutton&promo=new_regbutton_en&crea=img&' + paramList;
    }
    window.location = link; 
}

use window.open(URL,name,specs,replace) name as "_self "

 window.open(link, "_self" , "width=642, height=620, scrollbars=no,  menubar=no, status=no, scrollbars=no, resizable=yes,screenX=5, screenY=5, left=5, top=5");

You can load a new document into the current window with window.location.assign(link).

See http://www.w3schools./jsref/obj_location.asp

Before you call the base_window.open() method try to alert the link variable. If its 
okay then you may not have problem with that.

Thanks.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744244886a4564878.html

相关推荐

  • html - Javascript - opening a link - Stack Overflow

    My Javascript isnt up to scratch, and im having problems making the link open in the same window rather

    8天前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信