首页 \ 问答 \ window.open页面加载(window.open on page load)

window.open页面加载(window.open on page load)

我正在尝试加载页面时加载窗口。 如果我尝试使用按钮打开窗口代码可以工作。

我用的是:

$(document).ready(function() {
window.open ('http://google.com/', 'newwindow', config='height=720,width=1064, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no');
});

但是,它没有加载窗口。

有什么建议吗?

$(document).ready(function() {
  window.open('http://google.com/', 'newwindow', config = 'height=720,width=1064, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no');
  $('.open_webmail').click(function() {
    window.open('http://google.com/', 'newwindow', config = 'height=720,width=1064, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no');
  });
});
.open_webmail {
  background-color: rgba(0, 124, 255, 0.7);
  color: white;
  font-size: 18px;
  cursor: pointer;
  -webkit-transition: all 550ms ease-in-out;
  transition: all 550ms ease-in-out;
  -moz-transition: all 550ms ease-in-out;
  -o-transition: all 550ms ease-in-out;
  -ms-transition: all 550ms ease-in-out;
  display: inline-block;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  width: 200px;
  height: 100px;
  margin: auto;
}
.open_webmail:hover {
  background-color: rgba(163, 0, 255, 0.7);
  color: #c5c5c5;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<button type="button" class="open_webmail">Login</button>


I am trying to load a window when the page is loaded. If I try to open the window using a button the code works.

I iam using:

$(document).ready(function() {
window.open ('http://google.com/', 'newwindow', config='height=720,width=1064, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no');
});

However, it is not load the window.

Any suggestion?

$(document).ready(function() {
  window.open('http://google.com/', 'newwindow', config = 'height=720,width=1064, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no');
  $('.open_webmail').click(function() {
    window.open('http://google.com/', 'newwindow', config = 'height=720,width=1064, toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, directories=no, status=no');
  });
});
.open_webmail {
  background-color: rgba(0, 124, 255, 0.7);
  color: white;
  font-size: 18px;
  cursor: pointer;
  -webkit-transition: all 550ms ease-in-out;
  transition: all 550ms ease-in-out;
  -moz-transition: all 550ms ease-in-out;
  -o-transition: all 550ms ease-in-out;
  -ms-transition: all 550ms ease-in-out;
  display: inline-block;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  width: 200px;
  height: 100px;
  margin: auto;
}
.open_webmail:hover {
  background-color: rgba(163, 0, 255, 0.7);
  color: #c5c5c5;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<button type="button" class="open_webmail">Login</button>


原文:https://stackoverflow.com/questions/30941887
更新时间:2022-10-30 07:10

最满意答案

让我们看看另一个接口驱动抽象工厂的场景

在开始之前,我们需要明确一个界面指定了需要完成的工作,并对输入和期望输出进行了细微的指示。 也就是说,它并没有强制要求输入和输出都需要明确定义,因为它们也可以被视为合同本身。 如果我们不完全清楚输入和输出结构如何,我们可以使用标记接口 ; 那些没有任何结构的人..

比方说,我们有一个购物车,我们需要提供付款选项。 常见的选择是netbanking,信用卡和贝宝。 让我们有这个场景的定义

public interface ICustomerAccountInformation {  }

public interface IPaymentClient {  }  // Identifies whom the payment is intended for

public interface ITransactionDetails : IPaymentClient {  }  // Identifies amount, beneficiary details to be reflected in customer account

public interface IPaymentStatus { }

public interface IPaymentProvider  { 
    IPaymentStatus ProcessPayment(ICustomerAccountInformation customerInfo, ITransactionDetails transaction);

}


public class PayPal : IPaymentProvider  {

    public IPaymentStatus ProcessPayment(ICustomerAccountInformation customerInfo, ITransactionDetails transaction)  {
           /* Open paypal's login page, 
             do its own checks and process payment. 
             Once successfull, send back to referrer with the payment status
           */
    }

public class NetbankingProvider : IPaymentProvider  {

    public IPaymentStatus ProcessPayment(ICustomerAccountInformation customerInfo, ITransactionDetails transaction)  {
           /* Redirect to bank selection
             redirect to bank's login page, 
             do its own checks and process payment. 
             Once successfull, send back to referrer with the payment status
           */
    }

在整个流程中,每个提供者都可以自由地询问所需的任何信息(有些只需要凭证,而另一些则需要OTP作为附加信息)。 他们也根据自己的结构返回状态。 但是,在逻辑层面上,如果付款成功或失败,它们将获取用户的凭证并返回一条消息

您可以设计工厂独立于任何其他提供商设计。 只需在每个合同上都有标记界面。

在执行DI代码(比如NInject )时,使用“ WhenInjectedInto ”或类似的构造将正确的实现注入到每个正在使用的提供程序中。 您的工厂将根据用户的选择提供使用,而不会影响您的核心业务流程。

DI的主要规则是将非核心业务从核心业务完全抽象出来。 核心业务不应该关心每个提供商的期望,只是想要预测功能。 标记接口最适合这种要求,尤其是在您开始设计但尚未完全清晰的情况下。 您可以稍后改进标记界面,因为您可以更清楚地了解所涉及的过程。

让我知道你是否需要进一步清晰的设计。


Lets take in another scenario for interface driven abstract factory

Before starting, we need to be clear that an interface specifies what needs to be done, with a subtle indication of input and desired output. That said, it does not enforce that the input and output both need to be well defined, in that, they can also be taken as contracts themselves. If we are not completely clear about what the input and output be structured as, we can use marker interfaces; those without any structure at all..

Lets say we have a shopping cart and we need to provide for payment options. The common choices are netbanking, credit cards and paypal. Lets have the definitions of this scenario

public interface ICustomerAccountInformation {  }

public interface IPaymentClient {  }  // Identifies whom the payment is intended for

public interface ITransactionDetails : IPaymentClient {  }  // Identifies amount, beneficiary details to be reflected in customer account

public interface IPaymentStatus { }

public interface IPaymentProvider  { 
    IPaymentStatus ProcessPayment(ICustomerAccountInformation customerInfo, ITransactionDetails transaction);

}


public class PayPal : IPaymentProvider  {

    public IPaymentStatus ProcessPayment(ICustomerAccountInformation customerInfo, ITransactionDetails transaction)  {
           /* Open paypal's login page, 
             do its own checks and process payment. 
             Once successfull, send back to referrer with the payment status
           */
    }

public class NetbankingProvider : IPaymentProvider  {

    public IPaymentStatus ProcessPayment(ICustomerAccountInformation customerInfo, ITransactionDetails transaction)  {
           /* Redirect to bank selection
             redirect to bank's login page, 
             do its own checks and process payment. 
             Once successfull, send back to referrer with the payment status
           */
    }

In the entire flow, each of the providers are free to ask for whatever information is required (some just take the credentials while others ask for OTP as additional). They also return status back as per their own structure. However, at a logical level, they take user's credentials and return back a message if the payment was successful or not

You can design the factories to be independent of any other provider design. Just have the marker interfaces over each contract.

When doing the DI code (say NInject), use the "WhenInjectedInto" or similar construct to inject the correct implementation into each provider being used. Your factories will be available for use based on user's selection, without impacting your core business flow.

The main rule of DI is to to entirely abstract out the non-core business from the core one. The core business should not care about what each provider expects, just to have a faint idea about expected functionality. Marker interfaces suit this requirement best, especially when you have started design but are not completely clear. You can later improve the marker interfaces as you get more clarity into the process involved.

Let me know if you need further clarity into design.

相关问答

更多
  • 首先:根据需要将简单的依赖项添加到您的构造函数中。 不需要为每个构造函数添加每个类型,只需添加所需的类型即可。 需要另一个,只需展开构造函数即可。 性能不应该是一件大事,因为这些类型中的大多数都可能是在第一次调用之后就已经创建的单例。 不要使用静态DI容器来创建其他对象。 相反,将DI容器添加到自身,以便它可以将其自身解析为依赖项。 所以像这样的事情(假设目前是统一的) IUnityContainer container = new UnityContainer(); container.RegisterI ...
  • 我一定会选择D项目。 有时你会在解决方案中看到它甚至没有共享接口,或者意味着共享,这显然是过度的,但我会说,对于你的情况,这将是最好的方法。 现在,您可能想要做的不仅仅是将其作为dll或项目引用,因为 您将不得不编译和链接此项目,这将需要时间。 即使该项目中没有代码,但链接时间仍将发生。 您将无法轻松地对界面进行版本控制,因此在一个项目中编辑界面并进行重大更改需要立即在其他项目上进行传播,您不会知道是否已经完成了。 为了避免这两个问题,我将在这个项目D中创建一个NuGet包。你不需要在NuGet.org上托 ...
  • 所以另一种方法是创建一些较小的Facade服务,然后将这些服务注入到主门面。 例如,您可以为INavigationService和INavigationService创建更小的外观: public class GeographyService : IGeographyService { public GeographyService( INavigationService navigationService, ILocationService locationSer ...
  • 没有错误或无用的依赖注入这样的东西所以我建议总是使用它:) 它使您的代码更具可扩展性,更易于测试并且更具可读性(因为依赖关系清晰可见)。 其次,在确定新项目的要求时,我应该使用什么标准来确定是否应该使用依赖注入? 您可以避免它进行原型设计,或者您正在构建一些不会在生产环境中使用的东西。 在不使用依赖注入的情况下创建大型项目是否可行? 是的,但我不建议这样做 它需要大量的初始设置,有时似乎没有必要快速简单的程序。 Asp.MVC对依赖注入有很好的内置支持。 你可以很快设置它。 这只是nuget包安装的问题 。 ...
  • 在ASP.NET Core应用程序中,您可以通过扩展Startup.ConfigureServices方法在Startup.cs配置服务。 IServiceCollection实例的services参数允许您添加自己的实现接口的服务。 Startup.cs public void ConfigureServices(IServiceCollection services) { // setup of ASP.NET Services like MVC ... services.Ad ...
  • 让我们看看另一个接口驱动抽象工厂的场景 在开始之前,我们需要明确一个界面指定了需要完成的工作,并对输入和期望输出进行了细微的指示。 也就是说,它并没有强制要求输入和输出都需要明确定义,因为它们也可以被视为合同本身。 如果我们不完全清楚输入和输出结构如何,我们可以使用标记接口 ; 那些没有任何结构的人.. 比方说,我们有一个购物车,我们需要提供付款选项。 常见的选择是netbanking,信用卡和贝宝。 让我们有这个场景的定义 public interface ICustomerAccountInformat ...
  • 您的连接信息将在MySQLDB类中,因此您可以使用以下内容: class MySQLDB implements IDatabase { private $pdo; // Holds the PDO object for our connection // Or you can remove the parameters and hard code them if you want public function __construct( $username, $password, ...
  • 坚持最佳实践,设计模式或其他习语的优势在于,尽管您现在做了一些额外的努力,但从长远来看,您获得的收益更多。 想象一下你在团队中工作的场景,有多个开发人员,有些经验丰富,有些没有。 您是Zoo机制的创建者,但您决定,暂时,您将在KISS原则上实现Zoo,而不添加额外的抽象。 你为自己设定了一个心理记录(或者甚至是一个不错的小评论),指出“如果RoboticFeedingSvc有多个不同的行为,那么依赖注入就会有抽象!”。 现在,由于你真的很棒的工作,你可以去度假,一些初级开发人员将继续保留你的代码。 开发人员 ...
  • 也许我误解了你的问题,但是EDMX生成的继承自ObjectContext的代码不会阻止你使用依赖注入。 这听起来像是担心无法将ObjectSet注入到存储库中,但这不像它被设计用于的方式。 通过一个通用的存储库模式,例如在这里找到的模式,IRepository接口就是您注入ViewModels / Controllers / Whatever的东西。 因此,您不要将IObjectContext或IObjectSet注入存储库; 相反,您将IRepsoitory注入需要它的类中,并提供使用ObjectSet的 ...
  • 它只是因为你注入一个实现而不知道它是哪一个。 这是正确的,该示例不提供相同接口的N个实现,以免使其过于复杂,目标只是展示注入的工作原理。 It is DI just because you get injected an implementation without knowing which one it is. That's right that the example doesn't provide N implementations of the same interface to not make ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)