简体   繁体   English

parent.location在Firefox和Chrome中不起作用,但在IE6中起作用

[英]parent.location is not working in Firefox and Chrome but working in IE6

JSP Problem: JSP问题:

<A NAME="CustomerInformation"></A>
<table class="SectionHeader1">
    <TBODY>enter code here
        <tr>
            <td>Customer Information</td>
        </tr>
    </TBODY>
</table>
<INPUT type="button" value="Customer Details" class="buttonSuper" 
       onmouseover="onMouseOverButton(this)" onmouseout="onMouseOutButton(this)" 
       name="customerDetails" style="" 
       onclick="parent.location='#CustomerInformation'">

This code is working on IE6 but not working in Chrome or Firefox. 此代码在IE6上有效,但在Chrome或Firefox中不起作用。 Onclick I'm trying to go on same window. 我正在尝试在同一窗口上单击。 Could you please suggest what is problem? 您能提出什么问题吗?

If this is a pop-up, thr opener.location instead of parent.location . 如果是弹出窗口,请使用opener.location而不是parent.location If this is from an Iframe and the parent is on a different domain, it will not work due to the Same Origin Policy. 如果来自Iframe,且父级位于不同的域,则由于相同的原产地政策,它将无法使用。

This is unclear in your question. 您的问题尚不清楚。

Your question is a bit unclear, as is your code. 您的问题以及代码也不清楚。 My interpretation was that you want a button that, when clicked, jumps to the Customer Details located on the same parent page. 我的解释是,您需要一个按钮,当单击该按钮时,该按钮会跳至位于同一父页面上的“客户详细信息”。 If that is the case, you can simplify your code. 在这种情况下,您可以简化代码。 I wrote a sample that has a button element and jumps down to a Customer Information table. 我编写了一个包含按钮元素的示例,并跳至“客户信息”表。 Some things to note: 注意事项:

  1. You don't NEED to do input="button", just works fine - but this code would work for as well. 您无需执行input =“ button”,就可以正常工作-但此代码也适用。

  2. If you want your current window to change its location, you can use javascript: window.location = {link here}; 如果您希望当前窗口更改其位置,则可以使用javascript:window.location = {link here}; however, in this case you can simply just add a link tag around the button element. 但是,在这种情况下,您只需在按钮元素周围添加一个链接标签即可。

  3. I added a tag around your table simply to add space between the button and the table; 我在桌子周围添加了一个标签,只是为了在按钮和桌子之间添加空间。 that way, you can see a jump in the page when the button is clicked. 这样,单击按钮后,您可以在页面中看到跳转。

Code: 码:

<!DOCTYPE html><html>
<head></head>
<body>
    <a href="#CustomerInformation"><button>Customer Details</button></a>

    <div style="padding-top:2500px;">
        <A NAME="CustomerInformation"></A>
        <table class="SectionHeader1">
        <TBODY>enter code here
        <tr>
            <td>Customer Information</td>
        </tr>
        </TBODY>
        </table>
    </div>
</body>
</html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM