admin管理员组文章数量:1182578
I don't know much at all about coding so hopefully i worded the question correctly.
What I am trying to do is link a person to a specific modal window on another website. In this example, I will use the Menards weekly ad to show what I would like to do.
I would like to link somebody directly to the weekly flyer page with the modal window already open for a specific product such as the $74.99 5 Shelf Unit, which when selected opens this window (.png). This is the window that I would like to directly link to somebody.
Is there a way to modify the URL to make this possible? About all I know how to do is how to link to a specific page of the URL which would look like this /main/flyer.html?page=5
One other thing to mention is if you go to the website that provides the ads, Flipp, it does allow you to directly link to the window
Thanks for any help!
I don't know much at all about coding so hopefully i worded the question correctly.
What I am trying to do is link a person to a specific modal window on another website. In this example, I will use the Menards weekly ad to show what I would like to do.
I would like to link somebody directly to the weekly flyer page with the modal window already open for a specific product such as the $74.99 5 Shelf Unit, which when selected opens this window (https://i.sstatic.net/ASzuI.png). This is the window that I would like to directly link to somebody.
Is there a way to modify the URL to make this possible? About all I know how to do is how to link to a specific page of the URL which would look like this /main/flyer.html?page=5
One other thing to mention is if you go to the website that provides the ads, Flipp, it does allow you to directly link to the window https://flipp.com/item/175356457-muscle-rack-5shelf-steel-unit
Thanks for any help!
Share Improve this question asked Feb 1, 2017 at 2:50 RyanRyan 1111 gold badge1 silver badge4 bronze badges4 Answers
Reset to default 21Yes it is possible with some javascript, it will look for #myModal on the url if it finds it, it will load the modal:
just put this at the end of your page:
$(document).ready(function() {
if(window.location.href.indexOf('#myModal') != -1) {
$('#myModal').modal('show');
}
});
Now just use the following url:
http://www.mywebsite.com/page.html#myModal
*your modal must have an id:
<div class="modal" id="myModal">
How about that?
function openModalOnHash() {
if(window.location.hash) {
var hash = window.location.hash.substring(1);
$('#'+hash).modal('show');
}
}
$(document).ready(function() {
openModalOnHash()
});
I believe this should work. Only opens modal (if modal exist) with specified ID in URL
$(document).ready(() => {
const href = window.location.href
const modalID = href.split('/').reverse()[0]
if(modalID){
$(modalID).modal('show')
}
})
Yes, you can catch get param on url , https://www.exampleurl.com/?param=ModalIdShow
// Start Page
$(function(){
var param = GetURLParameter('param');
if(param == 'ModalIdShow'){
$("#ModalIdShow").modal("show");
}
});
//Catch param
function GetURLParameter(sParam)
{
var sPageURL = window.location.search.substring(1);
var sURLVariables = sPageURL.split('&');
for (var i = 0; i < sURLVariables.length; i++)
{
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == sParam)
{
return sParameterName[1];
}
}
}
本文标签: javascriptLinking Directly To An Open Modal Window Through a URLStack Overflow
版权声明:本文标题:javascript - Linking Directly To An Open Modal Window Through a URL? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738298212a2073483.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论