How can i add a link to notyjs text message - javascript

I've been trying to put a link in a message that im sending using notyjs (http://needim.github.io/noty/). I don't want to use a noty button, just a link.
var n = noty({text: 'Hi there click, here to continue'});
The problem is that the message shows with the link, but when i click. it does nothing.
any ideas? thanks

By default noty closes on clicking anywhere in the container. To prevent this you should change the closeWith parameter. The modified code is as below.
var n = noty({text: 'Hi there click, here to continue',closeWith:['button']});
JS Fiddle : http://jsfiddle.net/nGDvU/

Related

Escape handling in popup using javascript

I have a page at which when clicked on a button a popup appears and in that popup I have given a link which shows another popup . The problem here is when I handled the escape button in first popup , it worked fine . But when I am handling the escape button in second popup , when it is pressed both the popups are getting closed . But the need is if I press the escape button in second popup , only the second popup must close .Do anyone have the solution for this .
Thanks in advance ...
This has to be done with simple algorithm.
Define a variable, say var currentPop = 0;
When first pop-up is shown (or when first button is clicked)
set it to 1, currentPop = 1;
When second pop-up is shown (or when second button is clicked)
set it to 2, currentPop = 2;
Now, in the escape kay handling code: Write an algo. to hide appropriate pop-up.
function escapeHandling()
{
if(currentPop == 2)
{
$("#secondPop").hide();
}
else if(currentPop == 1)
{
$("#firstPop").hide();
}
}
*Provide me your code if you want exact fix!!!

Show popup message when click Browser Back button Using Javascript

When user click on browser back button, user will see a alert message for that I am using below code.
window.onbeforeunload = function () { return "If you want to go back to previous page Please use Previous step Button in below"; };
But in the code I have written "If you want to go back to previous page Please use Previous Step Button in below". This message is not displaying in alert box,instead of that message it is showing another message:
.
How can I display my own message in the alert box?
You will need to put javascript/jquery code you want to use on a handler for beforeunload event
window.addEventListener("beforeunload", function (event) {
//your code goes here. Create modal window or whatever you need
});

How to click a Button By matching a text.?

I am very New to JavaScript. Now i am trying to make a Google Chrome Extension which a click a Button on a specific web address. But the Site opens only for 30 second.. So i just saw the button color is GREEN and the button text is- " Move To "
so how can i trigger that button ? I am Trying for this. But its not Working.
var b = $('button[class*="Move To"]')[1]
$(b).click();
You can use :contains.
var b = $( "button:contains('Move To')" )[1]
b.trigger('click');
https://api.jquery.com/contains-selector/
Or if text is exactly Move To you can use this:
var b;
if($('button').text() == 'Target'){
$('button').trigger('click');
}
fire click event on a button containing particular text
js
$("button:contains('Move To')").trigger( "click" );
HTML
<button id="btn">Move To</button>

Chrome getSelection not working if called from context menu

I'm working on a Chrome extension but I don't seem to be able to go past the first few lines.
The problem is that when I click on the context menu it fails to grab the selection from the document. It works fine obviously when I use it as a simple script included in an HTML page.
Here's the code:
var id = chrome.contextMenus.create({
"title" : "Search",
"contexts" : ["selection"],
"onclick" : openUrl
});
function openUrl() {
var sel = window.getSelection().toString().trim()
alert(sel)
}
This code returns an empty alert box.
I have a script that on mouseup grabs the word that the user has selected and searches for this word on a dictionary. This script works fine I just need to execute it when the user clicks "Search" in the context menu.
So what I'm looking for is:
1) User selects a word from the document
2) Right clicks on it and clicks on the context menu
3) The script containing all instruction to be executed on that click.
I looked around before asking this question but I couldn't find anything probably because I'm pretty new to this awesome site. Please feel free to redirect me to other similiar question if I missed any. Thanks!
function openUrl(info, tab) {
alert(info.selectionText);
}

Change href with JavaScript

I am trying to add a click event to a link in SharePoint.
The current href set by SharePoint is href="javascript:ClickOnce()".
If I add the following code:
var saveNclose = document.getElementById("diidIOSaveItem");
saveNclose.href = "javascript:JSEPreSaveAction()";
alert(saveNclose.href);
The alert outputs the href I am trying to get, which is javascript:PreSaveAction() but when I look at it in the page it is still ClickOnce().
Why is the alert telling me the href is one thing and the source code and behavior says is another? Is there something causing SharePoints script to take priority over mine?
document.getElementById("diidIOSaveItem").setAttribute("href", "javascript:JSEPreSaveAction()");
alert( document.getElementById("diidIOSaveItem").getAttribute("href") );
I was able to do this by adding a timer to add PreSaveAction() to the button 10 seconds after the page had finished loading.

Categories