How can we show Nifty window modal popup on page load? [duplicate] - javascript

This question already has answers here:
Nifty Modal - how to trigger a modal without a button
(7 answers)
Closed 7 years ago.
I want to show my nifty window modal popup on page load. This is my nifty window popup modal code:
<div class="md-modal md-effect-1" id="modal-1">
<div class="md-content">
<h3>Modal Dialog</h3>
<div>
<p>This is my first nifty modal window. </p>
<button class="md-close">Close me!</button>
</div>
</div>
</div>
Thanks in advance.

I've looking in to the source code of the demos, and I believe that this would do the trick:
$(function() {
$('#modal-1').addClass('md-show');
});

Related

Trying to understand the following HTML code [duplicate]

This question already has an answer here:
what are data-* HTML attributes?
(1 answer)
Closed 4 months ago.
<div class="off-canvas-wrap" data-offcanvas>
<div class="inner-wrap home">
<nav class="header row">
</nav>
<!-- Off Canvas Menu -->
<aside class="right-off-canvas-menu">
<!-- close the off-canvas menu -->
<!-- whatever you want goes here -->
<div class="close">
In the first line, I can understand after div the class. Then, data-offcanvas. What is this? I noticed this while viewing the "view source page" of a web page.
Please help me to understand above html code.
data-offcanvas is a non standard or custom attribute which in this case appears to have no value.
You can read more in this here:
https://www.w3schools.com/tags/att_data-.asp

Preventing Specific Anchors from Adding Irrelevant Entries to Browser History? [duplicate]

This question already has an answer here:
Is There an Alternative Method to Mimic the Behavior of an Anchor Link/Target Pseudo-Class?
(1 answer)
Closed 5 years ago.
Is it possible to prevent selected anchors from adding to the browser's history?
For a site I am working on now, this is a particular issue when I try to prompt back to a previous page. By doing so the anchors repeat in the order they where activated, and I have to click back more than once before returning back to the previous page.
Here's some code I am currently working with. Is there a function I can implement to achieve this result?
<!-- Image with Anchor to Open Lightbox Window -->
<div class="container">
<a href="#view">
<div class="pic">
<img src="https://URLTOPIC.jpg">
</div>
</a>
</div>
<!-- Lightbox Prompt with Anchor to Close Window -->
<div class="customlightbox lb-animate" id="view">
<div class="customlightbox-imgwrap">
<img class="imgsrc" id="customlightbox-img" src="">
</div>
</div>
<div id="customlightbox-controls" class="lb-animate">
<a id="close-customlightbox" class="lb-animate" href="#!"></a>
</div>
Any help would be much appreciated!
When using a empty anchor, for example <a id="close-customlightbox" class="lb-animate" href="#!"></a> which is used as a button, you can set the href this way that will disable the anchor events <a id="close-customlightbox" class="lb-animate" href="javaScript:void(0);"></a>
You can read more about the javascript URI scheme What does "javascript:void(0)" mean?
For the links you are using to trigger the models, avoid the default behavior for it to be added to the window.history object
document.querySelector('.trigger').addEventLister('click', function(e){
e.preventDefault();
//Do your stuff
});

How to use Greasemonkey to remove a href block [duplicate]

This question already has answers here:
Greasemonkey, delete <a> element
(2 answers)
Closed 7 years ago.
I'm trying to remove the following line of code from http://trakt.tv/calendars/my/shows/ using Greasemonkey:
<a href="/vip">
<div class="huckster-vip-square">
<div class="inner">
<div class="text">
<h1>Support Trakt & become a VIP!</h1>
<h2>Hide advertising, unlock extended features and help Trakt grow.</h2>
<div class="btn btn-primary">Learn More</div>
</div>
</div>
</div>
</a>
How can I do that?
You may try it with jQuery.
Please refer to this question for using jQuery in Greasemonkey.
The JavaScript code would be like:
$("a[href='/vip']").remove();

Zurb Foundation Reveal Modal - preventing close on background click

When I am opening my Reveal Modal, I would like to prevent it from closing on background click (which is a default behavior).
I am using Zurb Foundation 5.0.2.
Any help would be appreciated.
If you set the closeOnBackgroundClick option to false then your modal won't close when you click in the background.
<div class="reveal-modal" data-options="closeOnBackgroundClick:false">
Yehhhhh Finally Found It:
Put below code on your foundation reveal model. Than it not close by clicking on background or by pressing esc key.
data-options="close_on_background_click:false;close_on_esc:false;"
Ex:
<div id="AccessContainer" class="reveal-modal" data-reveal data-options="close_on_background_click:false;close_on_esc:false;">
</div>
For anyone looking at this question in 2018, I'm using Version 6.4.0 and this works:
data-close-on-click="false" data-close-on-esc="false"
I added that to the reveal div like this and it's working (as of July 2018):
<div class="reveal" id="modalVideo" data-reveal data-close-on-click="false" data-close-on-esc="false">
You can achieve this globally by executing the following line of JavaScript before showing any modals:
Foundation.libs.reveal.settings.close_on_background_click = false;
For latest version of foundation by zurb use following snippet
<div id="myModal" class="reveal-modal" data-options="close_on_background_click:false" data-reveal>
Complete Code will look like
Click Me For A Modal
<div id="myModal" class="reveal-modal" data-options="close_on_background_click:false" data-reveal>
<h2>Awesome. I have it.</h2>
<p class="lead">Your couch. It is mine.</p>
<p>I'm a cool paragraph that lives inside of an even cooler modal. Wins!</p>
<a class="close-reveal-modal">×</a>
</div>
If using the stand-alone Reveal plugin here: https://zurb.com/playground/reveal-modal-plugin
Use the following on the link that opens the modal.
Open Modal
This answer applies to Foundation 6. Below are the correct option for both preventing close on background click (closeOnClick:false;) and preventing close via the Esc key (closeOnEsc:false;).
<div class="reveal" id="exampleModal1" data-reveal
data-options="closeOnClick:false; closeOnEsc:false;">

Cannot open JQuery UI dialog more than once on Drupal

I've checked my code and it works fine but for some reason I cannot open Dialog once it was closed. Any advice on why is that?
The code is here - http://jsfiddle.net/EA2Dg/1/
Why don't you use "click function to open the dialog, it should work
HTML
<div id="dialog" title="Basic dialog">
<p>This is an animated dialog which is useful for displaying information. The dialog window can be moved, resized and closed with the 'x' icon.</p>
</div>
<button id="opener">Open Dialog</button>
JQuery:
<script>
$(function(){
$("#opener").click(function(){
$("#dialog").dialog();
});
});
</script>

Categories