Whatsapp only sharing first parameter of window.location.search - javascript

I have a whatsapp share button that shares the current URL (using window.location)
waCurrentPage = function() {
return encodeURI("whatsapp://send?text=Lets go here: " + 'http://' + window.location.hostname + window.location.pathname + window.location.search);
}
Button
<a class="btn btn-social-icon btn-whatsapp" href="javascript:window.location=waCurrentPage();">Whatsapp share this list</a>
I can see that from the browser side it's sending the correct URL...
...but when it gets to the whatsapp side it has cut off the second parameter
Anyone have an idea how I could fix it?

Related

Suddenly Chrome started blocking popup

I am working on an affiliate website for which redirect is the most critical part. I used a simple script to pop open links in a new window. But since last week suddenly chrome started blocking these popups.
$(".get-code").click(function() {
$couponId = $(this).attr("data-coupon-id");
$url = $(this).attr("data-coupon-url");
$outUrl = $(this).attr("data-out-url");
//alert("Coupon Id: " + $couponId + " URL: " + $url + " Redirect URL: " + $outUrl);
window.open($outUrl, '_self');
window.open($url, '_blank');
});
Does anyone have any idea about this?
I fixed it by breaking both the redirection into two parts.
One redirection is done on the click event and another one is using the href link of the anchor tag. This way chrome doesn't block it and also works fine in IE and Firefox.
<a rel="noopener noreferrer" onclick="return hitTarget('URL1')" href="URL2" >GRAB CODE</a>
JavaScript redirection
function hitTarget(target){
window.open(target,'_blank');
return true;
}

How can I redirect a page to itself in JavaScript?

Here is my current code which does redirecting:
window.location.href= '/post/' + data.main_id + '/' + subject + '#post-' + data.post_id;
Code above just changes the slug when I'm in the same URL. anyway, I need to both change the slug and reload the page. How can I do that by JS or even jQuery?
You can achieve this by first appending the fragment to the URL, then reloading the page:
window.location.href += '#post-' + data.post_id;
window.location.reload();
Note however that you could improve this further by using pushState and avoiding the need to reload the page at all when the fragment changes.
You can use
location.reload();
Please, see
http://www.w3schools.com/jsref/met_loc_reload.asp

Open pdf in new tab with jQuery

I've the following code working properly which opens a pdf downoloaded in the same window:
jQuery('<form action="'+ url +'" method="'+ (method||'post') +'">'+inputs+'</form>')
.appendTo('body').submit().remove();
I'd like open the pdf in a new tab or window.. How can I change the appendTo in order to achieve it?
Thanks in advance!!
You can set target="_blank"
jQuery('<form target="_blank" action="' + url + '" method="' + (method || 'post') + '">' + inputs + '</form>')
.appendTo('body').submit().remove();
Add target='_blank' attribute into forms.
target="_blank"
I think you can use $.ajax or $.post to get pdf url and you can use window.open() to open this url in new tab:)

Pinterest share without pin it button

Can I create pinterest share without pin it button? I had try using these but it seem fail.
Pin it
Pin it
Is there any way I can create a pinterest share link without pin it button?
Try making your hyperlink url like this, this worked for me
string url = "http://pinterest.com/pin/create/button/" +
"?url=" + "your link" +
"&media=" + "link to youre image" +
"&description=" + "your description";
both media and description can be blank so you could do
string url = "http://pinterest.com/pin/create/button/" +
"?url=" + "" +
"&media=" + "" +
"&description=" + "";
to test it out
in my code im calling a redirect after a button press but i think this should work for you.

Stopping custom protocols opening in new tab

Ive got a url to a custom protocol (i.e. myproto://dosomething) and i can get it to work but when a user clicks on the url it redirects the page before popping up the "do you want to open this url" dialog.
Is there any way to have the custom protocol to work with out the redirect?
For example:
Page:
<html>
<body>
My Url
</body>
</html>
When user clicks link, browser redirects to blank page with myproto://dosomething as url and shows popup. What im trying to do is have it so that the popup shows but stays on the main page.
So i found a solution to this issue: iframes
var launchLink = function(href) {
var url = ProtoRedirectUrl + '?' + $.param({ url: href });
$('<iframe src="' + url + '" width="1px" height="1px">').appendTo('body');
}
This causes the url to be loaded and the browser redirects the iframe window to the blank page instead of the main window.

Categories