Hide div via cookie detection using JavaScript - javascript

Objective: To hide an embedded Mailchimp subscribe form from subscribed users, by placing a cookie in their browser after subscribing, which causes the form to be hidden via JS.
What I have so far:
The Subscribe Form is configured, via Mailchimp's settings, to redirect users to a page that contains the following code:
<body>
<script type="text/javascript">
<!--
Cookies.set('subscriber', 'yes');
//-->
</script>
</body>
When the user returns to the homepage, this code should execute:
<script type="text/javascript">
<!--
if ($.cookie('subscriber')) {
mc_embed_signup.style.display = 'none';
}
//-->
</script>
However the form is still displaying. What am I doing wrong?
Site is http://dev.mistcalls.com
Page with cookie creation code is http://dev.mistcalls.com/subconfirm.html`
Cheers

Related

Loading a html script from a typescript file

Im am currenlty working on a integration of a nps widget within a Chatbot. I cannot show you all the code, but i imported the html file inside the chat.ts file. I want to call the entire html file after a button press from the chatbot. I have tried a lot, but nothing seems to help.
this is the chat.ts code (small part of it)
private showAskNicely() {
// #ts-ignore
window.location.assign('npshtml.html');
}
private askNicelyButton() {
const el = document.getElementById('detractbut');
el.addEventListener('click', this.showAskNicely);
}
this is the npshtml file
<html>
<body id="try">
<p>
AskNicely Web Survey Popup Example for traditional websites.<br>
Running in 'force' mode.<br>
Responses will be recorded.
</p>
<script type="text/javascript" src="https://static.asknice.ly/dist/standalone/asknicely-in-app-conversation.js"></script>
<link href="https://static.asknice.ly/dist/standalone/asknicely-in-app-conversation.css" rel="stylesheet" type="text/css" charset="utf-8">
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', function () {
askNicelyConversation({
config: {
--- cannot show this part ---
},
customData: {
a_custom_property: 'business', // Optional - Send extra data about this customer for reporting and leaderboards
another_custom_property: 'New York' // Optional - Send extra data about this customer for reporting and leaderboards
}
});
});
</script>
</body>
</html>
I also have the button rendered inside another html file with css, but that all works fine.
I have it currently on windows.location.assign, so that it opens a new page. It would be ideal if the script could be triggered without opening a new page.
Using jquery.load does not work and does not give me a error of some sort.

How to code sending an email upon pushing a button on a list view

I am creating a page that displays users based on a view and I would like to add a button to this view that will send off an email that has the subject filled in with the name of the site and some other text. Maybe even prefill some of the body.
I do not want to create a new field in the list because only a small portion of records will leverage this attribute (only those contacts that have a support role). The view only displays support role individuals. I tried to change the existing email link by adding the appropriate information, but I have no clue how to do this. My next attempt was to add a button and then code behind this button. This has to be only client changes, nothing with master pages. This is the code I have. I can call an alert, but not able to put my email string in their to make it work or to call a local js function. Neither one of these work.
I'm know JS, but I'm no master
<script language="javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function(){
document.getElementById('pageTitle').innerHTML=document.title;
_spBodyOnLoadFunctionNames.push("buttons");
});
function buttons()
{
var $t = $('#js-listviewthead-WPQ2').next().next().find('tr');
$t.each(function(){
// $(this).append("<input type='button' value='Help' id='btnSub' onclick='alert(document.title);'/>");
$(this).append("<input type='button' value='Help' id='btnSub' onclick='Steve#wi.gov'>");
});
}
</script>
Email opens up with the subject pre-filled.
We can use the code below to achieve it.
<script src="https://code.jquery.com/jquery-1.12.4.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
addButtons();
});
function addButtons(){
var listTitle="CustomList";
$("table.ms-listviewtable[summary='"+listTitle+"']>tbody>tr").each(function(){
$(this).append("<input type='button' value='Help' id='btnSub' onclick='javascript:openMail();'>");
});
}
function openMail(){
location.href="mailto:Steve#Wi.gov?subject=SharePoint Site Support";
}
</script>

Load Javascript with Magento Block template

I have put javascript into a custom payment method block template .phtml like so:
<ul class="form-list" id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none;">
<div>
<script type="text/javascript">
//<![CDATA[
...
//]]>
</script>
</div>
</ul>
the Javascript controls the disabling and showing of input fields in my custom payment method form.
But the script does not load when my payment method custom form appears.
I was able to place the script into the head of the checkout html page using layout block reference.
But that does not work since the payment method custom form is loaded after the JS is loaded.
I'm just trying to load the JS with the form, but that does not work. How can I do this?
You can try:
alert('here') / console.log('here') in the script to make sure it got called.
wrap your script in:
document.observe("dom:loaded", function() {
// your scripts
}
To make sure it load last.

JS error "hX_6 is not defined"

I'm using RAD 7.5.6, and JSF 1.2, and IBM JSF client framework (the hx taglib).
I have a search page, where within a list of items, I can edit my selected item.
When I click on the item, I'm redirected to the insert page, with all my items data.
My page is load with all the data, but I got a JS error, what I tracked to the following code, with the message "hX_6 is not defined":
<script type="text/JavaScript" language="JavaScript">
if (hX_6) hX_6.setResourceServer("/APHP0000_Web/.ibmjsfres");
if (hX_6 && hX_6.setLocale) hX_6.setLocale("pt_BR");
</script>
and
<script type="text/javascript" src="/APHP0000_Web/.ibmjsfres/hxclient_be_v3_1_4.js"> </script>
<script type="text/javascript">
hX_6.onPageLoad();
</script>
This error affects my menu and all the other JS and submissions of the page.

adding an modal window on jsp page onload

I am new to the jsp. I am creating a jsp page.Index.jsp, I want that when this index.jsp is loading one modal pop up should appear that would ask the user to enter some information.Please let me know how to add it.
You can do something like this using jQuery.Download jQuery file and place it under your webapps directory,
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(showWindow());
function showWindow(){
window.open('mathutil.jsp','myWindow','height=255,width=250,toolbar=no,directories=no,status=no,continued from previous linemenubar=no,scrollbars=no,resizable=no ,modal=yes');
}
</script>
This will be called before your JSP page get loaded.
If you want something as soon as page get loaded (e.g. wait until all assets have finished downloading, such as images and scripts.) use onload() in your body tag.

Categories