HTML5 Responsive Notify Support Product Page
Solved
Hallo, how I can call the script only when a variable is set?
Reported 26 Jun 2013 13:51:08
1
has this problem
26 Jun 2013 13:51:08 Carmen Scheibe posted:
Hallo, how I can call the script only when a variable is set.<script type="text/javascript"> if (document.URL.indexOf('Var') != -1){ body.on.onload= "dmxNotifyAction({"msg": "Artikel erfolgreich hinzugefügt. ", "extendedTimeOut": 2000, "tapToDismiss": false})" }</script>
does not work
Replies
Replied 27 Jun 2013 06:32:17
27 Jun 2013 06:32:17 Miroslav Zografski replied:
Hello Carmen,
You like to display notification based on a certain URL variable ?
Regards.
You like to display notification based on a certain URL variable ?
Regards.
Replied 27 Jun 2013 08:01:16
27 Jun 2013 08:01:16 Carmen Scheibe replied:
Yes, that exactly I want do.
Replied 27 Jun 2013 08:53:09
27 Jun 2013 08:53:09 Miroslav Zografski replied:
Hello Carmen,
First you need to get the URL Variable. That you can do using following function:
and retrieve then the variable in following fashion:
Then you can check if that variable is set and is not empty and if so execute the dmxNotifyAction function with the requested arguments:
Your full code will be:
And must be placed right before the body closing tag in your page.
Also you must check if following scripts are available in your head already:
If those are not present in the page create a link and apply to it dmxNotify, so it could place those scripts in the page, and then remove the link.
Regards.
First you need to get the URL Variable. That you can do using following function:
function getUrlVars() { var vars = {}; var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) { vars[key] = value; }); return vars; }
and retrieve then the variable in following fashion:
var myVariable= getUrlVars()["URLVarName"];
Then you can check if that variable is set and is not empty and if so execute the dmxNotifyAction function with the requested arguments:
if(myVariable && myVariable!= ''){ dmxNotifyAction({"msg": "Your Message here", "extendedTimeOut": 2000, "tapToDismiss": false}); }
Your full code will be:
<script> function getUrlVars() { var vars = {}; var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) { vars[key] = value; }); return vars; } var myVariable = getUrlVars()["alabala"]; if(myVariable){ dmxNotifyAction({"msg": "Your Message here", "extendedTimeOut": 2000, "tapToDismiss": false}); } </script>
And must be placed right before the body closing tag in your page.
Also you must check if following scripts are available in your head already:
<link rel="stylesheet" type="text/css" href="Styles/dmxNotify.css" /> <script type="text/javascript" src="ScriptLibrary/jquery-latest.pack.js"></script> <script type="text/javascript" src="ScriptLibrary/dmxNotify.js"></script> <script> function dmxNotifyAction() { //ver 1.00 if (arguments && arguments.length > 0) { if(typeof arguments[0] == 'object'){ jQuery.dmxNotify(arguments[0]); }else if(arguments[0] === 'closeAll'){ jQuery.dmxNotify.closeAll(); } } } </script>
If those are not present in the page create a link and apply to it dmxNotify, so it could place those scripts in the page, and then remove the link.
Regards.
Replied 27 Jun 2013 10:32:26
27 Jun 2013 10:32:26 Carmen Scheibe replied:
Thank you so much. This works great. This is a really useful extension.
Replied 27 Jun 2013 11:35:41
27 Jun 2013 11:35:41 Miroslav Zografski replied:
You are welcome Carmen.
Regards.
Regards.