简体   繁体   English

锚标签会弹出div而不是新页面

[英]anchor tag pops up a div instead of a new page

I was wondering how to implement a popup div that had its own address. 我想知道如何实现一个有自己地址的弹出式div。 The example in question is the Chrome Extensions Store: https://chrome.google.com/webstore/category/extensions 相关示例是Chrome扩展程序商店: https//chrome.google.com/webstore/category/extensions

If you click a tile on that site, not only will the content pop up in form of a div, but it'll also have its own address. 如果单击该站点上的磁贴,不仅会以div的形式弹出内容,而且还会有自己的地址。 So if I copy the address and paste it onto a new window, it goes to the same popup. 因此,如果我复制地址并将其粘贴到新窗口,它将转到相同的弹出窗口。 Not only that, if you click back button (or backspace), it closes the pop-up div instead of going back to previous page. 不仅如此,如果单击后退按钮(或退格键),它将关闭弹出div而不是返回上一页。

If there is no simple way to implement this, I'd like to know what javascript object or something I'd have to learn about to do this. 如果没有简单的方法来实现这一点,我想知道javascript对象或我必须要学习的东西。

I'm not sure if this is the right SE forum to ask, but I had to ask someone. 我不确定这是否是正确的SE论坛,但我不得不问别人。

You can use bootstrap modal. 你可以使用bootstrap模态。 It's very good 这很好

here is the code, 这是代码,

 <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> <button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button> <!-- Modal --> <div id="myModal" class="modal fade" role="dialog"> <div class="modal-dialog"> <!-- Modal content--> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal">&times;</button> <h4 class="modal-title">Modal Header</h4> </div> <div class="modal-body"> <p>Some text in the modal.</p> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> </div> </div> </div> </div> 

I didn't see the link you are talking about but I think they are hack the behavior of the link and instead of going to the clicked url show it'e content on an popup div. 我没有看到你正在谈论的链接,但我认为他们是黑客链接的行为,而不是去点击的网址显示它是一个弹出div的内容。 in jquery you can do it by something like preventDefault 在jquery中,你可以通过preventDefault之类的东西来实现

If you click a tile on that site, not only will the content pop up in form of a div, but it'll also have its own address. 如果单击该站点上的磁贴,不仅会以div的形式弹出内容,而且还会有自己的地址。 So if I copy the address and paste it onto a new window, it goes to the same popup. 因此,如果我复制地址并将其粘贴到新窗口,它将转到相同的弹出窗口。

This is called stateless UI which can easily be achieved with for example router in Angular or Ember. 这被称为无状态UI,可以使用例如Angular或Ember中的路由器轻松实现。

The idea is that every state in your application has its own address. 这个想法是应用程序中的每个状态都有自己的地址。 If for example, your application has an entity user then the url to see a specific user would be 例如,如果您的应用程序具有实体user那么将查​​看特定用户的URL

http://example.com/user/12345

Where 12345 is userId 其中12345是userId

At the same time to open an edit form for this object you might use 同时打开您可能使用的此对象的编辑表单

http://example.com/user/12345/edit

Irrelevant of when you get to the latter, your application will always open an edit form for user with id=12345 与您到达后者的时间无关,您的应用程序将始终为id=12345用户打开编辑表单

To understand this better you need to get acquainted with some principles of MVC and perhaps examine ui-router tutorial as an example of implementation 为了更好地理解这一点,你需要熟悉MVC的一些原理,并且可能将ui-router教程作为实现的一个例子来考察

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

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