简体   繁体   English

asp.net应用程序javascript弹出窗口未显示

[英]asp.net app javascript popup window doesn't display

My imagebutton will not cause the popup window to appear when its clicked. 我的图像按钮在单击时不会导致弹出窗口出现。 Here is my code. 这是我的代码。

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script type="text/javascript">
    function goToAddNewsletterAddPage() 
    {
        window.open("Newsletter.aspx","mywindow");
    }
</script>

    <asp:Image ID="Image1" runat="server" Height="87px" Width="158px" ImageUrl="~/images/signup.gif" onclick="goToAddNewsletterAddPage()"/>

If you look in the console of the browser, you should see a syntax error. 如果在浏览器的控制台中查看,应该会看到语法错误。 Function declarations (the style you've used in your script) must have a function name, so there's a syntax error... 函数声明 (您在脚本中使用的样式) 必须具有函数名称,因此存在语法错误...

<script type="text/javascript">
    //    ...v-- here
    function () 
    {
        window.open("Newsletter.aspx","mywindow");
    }
</script>

Perhaps you meant: 也许您的意思是:

<script type="text/javascript">
    function goToAddNewsletterAddPage() 
    {
        window.open("Newsletter.aspx","mywindow");
    }
</script>

(There is a different, but related, thing called a function expression , which doesn't have to have a function name [and due to IE bugs is usually better off without one], eg: (有一个不同但相关的东西,称为函数表达式 ,它不必具有函数名称(由于IE错误 ,通常最好不使用一个函数名称),例如:

var x = function() { /* ... */ };

The key to knowing which is which is to look to see whether the function structure is being used as a right-hand value , eg, the right-hand side of an assignment [ = ] or initializer [ : ], or being passed into a function as an argument. 知道哪个是关键是看function结构是用作右侧值 ,例如,赋值[ = ]或初始化程序[ : ]的右侧,还是传递给作为参数。 If it is, it's a function expression; 如果是的话,那就是一个函数表达式。 if not, it's a function declaration.) 如果不是,则为函数声明。)

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

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