Twitter intent redirect to mobile.twitter.com - javascript

I am currently working on a project where we are able to share via twitter or facebook.
When I am working with twitter share, I found out twitter intent is the best way.
But I found a problem when I try to share via twitter using mobile device.
Here is my sample code:
var width = 640,
height = 440,
left = ($(window).width() - width) / 2,
top = ($(window).height() - height) / 2,
url = 'https://twitter.com/intent/tweet?text=Congrats!&hashtags=labmate!',
opts = 'status=1' +
',width=' + width +
',height=' + height +
',top=' + top +
',left=' + left;
window.open(url, 'twitter', opts);
if user already login, nothing is wrong, but when the user is not login twitter will show login form, and if the user misstype either the username or the password, twitter will redirect it to another page.
Here is the problem, after twitter redirect to another page, the url change into
https://mobile.twitter.com/login/error?username_or_email=sample%40mail.com&redirect_after_login=%2Fintent%2Ftweet%3Ftext%3DCongrats.......
when user finally login with the right username and password, twitter will redirect to
https://mobile.twitter.com/intent/tweet?text=Congrats
which is doesn't exist
What can I do? Much appreciate.

Related

Mobile URL Redirect and Desktop URL Redirect

I need help please? I want to make my website that has a desktop and a mobile version. The CSS coding of styling to the correct widths of HTML elements are easy but a URL is harder.
I want to know is that how to make a URL that leads to a home page on desktop but on mobile the URL is different but it goes to the same home page as the desktop version but in the mobile version.
Do you know if there is any code that can do that with out getting any errors on previewing it privately. I don't mind if your answers are using PHP or JavaScript etc.
This is a code that i tried to use. I wasn't sure if it worked or not. Can't say it possibly did.
$(document).ready(function() {
$(window).on("load resize", function() {
if($(window).width() <= 950) {
var mobile = window.location = "/mindex.php";
console.log("The location is " + mobile);
} else if($(window).width() > 950) {
var desktop = window.location = "/index.php";
console.log("The location is " + desktop);
} else {
var defaultPlace = "";
console.log("Defualt location: " + defaultPlace);
}
});
});
Can you please help me? Remember, I would like some help on making a mobile redirect URL and a desktop URL but that will both lead to the same page but in different versions please.
You can use user-agent header sent by the browser to check whether the user is mobile user or desktop user and redirect according to the returned value. You can check user-agent header using this -
var usrAgent = navigator.userAgent;
Now you know the user agent, check the returned user-agent is mobile or not and redirect accordingly -
function detectMobile()
{
if(usrAgent.match(/Mobile/i))
{
return "Mobile";
}
}
var isMobile = detectMobile();
if(isMobile)
{
window.location = "MOBILE_URL";
}
else
{
window.location = "DESKTOP_URL";
}
Alternatively,
You can use html link tag to redirect to any webpage according to user device width using this -
<link rel="alternate" media="only screen and (max-width: 640px*)" href="MOBILE_URL_TO_REDIRECT">
*Change this width according to your requirement. 640px is the ideal max width for mobile devices.
I hope this solves your problem.

Responsive File Manager. Prevent modal close on image select

The plugin is this: http://www.responsivefilemanager.com
I'm using the stand-alone feature in a bootstrap modal. Is it possible to prevent modal close on image select?
Responsive File Manager not support using the stand-alone feature in a bootstrap modal.
You can use javascipt popup instead of bootstrap modal.
Image
Do not forget add popup parameter and value (1) to URL dialog.php?type=1&popup=1&field_id
And popup open_popup method for JS.
function open_popup(url)
{
var w = 880;
var h = 570;
var l = Math.floor((screen.width - w) / 2);
var t = Math.floor((screen.height - h) / 2);
var win = window.open(url, 'ResponsiveFilemanager', "scrollbars=1,width=" + w + ",height=" + h + ",top=" + t + ",left=" + l);
}
First off this is a plugin so not garenteed to work with framework such as bootstrap.
Ideally would need to see your code to make a judgement on the problem.
A modal will close on "submit" as the modal is designed as a pop-up, you click something then it goes, you can place form elements in the modal, but soon as "submit" button is clicked, the modal closes. I would suggest looking at the coding (as i cant) and see if the image select function is casuing it to close.
Again place your code in a fiddle and we can all look at it better.

Open facebook app from cordova/phonegap app

I'm working on a cordova app.
I'd like to open a facebook page programmatiacally using javascript and I want to open that page using the facebook app (if installed) in the system (Android, iOS).
I tried:
var ID = 1010101010000;
var full_URL = "https://www.facebook.com/pages/page_name/" + ID;
window.open(full_URL, '_system');
window.open('fb:' + full_URL);
window.open('fb:' + 'https://www.facebook.com/' + ID);
window.open('https://www.facebook.com/' + ID, '_system');
but nothing works.
Can you help me?
Thanks
edit:
I tried:
window.open("facebook://pages/" + ID, '_system');
and similars, it just opens the facebook app but it does not redirect to the facebook page I want.

Share the link , title and one image in custom twitter share icon

Here is the custom twitter icon code:
HTML:
<i id="twitter_share" class="fa fa-twitter fs20" style="position: relative; bottom: 4px;"></i>
And Jquery:
$('#twitter_share').click(function (e) {
e.preventDefault();
var loc = "<?= base_url(uri_string()); ?>";
var title = "<?= $video->title; ?>";
window.open('http://twitter.com/share?url=' + loc + '&text=' + title + '&', 'twitterwindow', 'height=450, width=550, top=' + ($(window).height() / 2 - 225) + ', left=' + $(window).width() / 2 + ', toolbar=0, location=0, menubar=0, directories=0, scrollbars=0');
});
It works fine with the url and title. The problem is , how can I share one image as well?
Thanks a lot for helping.
Update: reference in facebook
in facebook I can share the content like this, can it be done in twitter as well? Thanks.
!
The image comes from your HTML markup, which is scraped by twitter when someone tweets your url.
Twitter refers to the collection of meta info accompanying a tweet as a card, which they need to approve before it will appear on the network.
Have a good read through the Twitter Cards Developer page
Select an appropriate card (summary_large_image is a good one) and include the appropriate twitter meta tags in the head of your HTML
Validate your card on the Cards Validator page
Once your domain has been whitelisted any tweets with your url will also include your card
I searched a little bit for a solution and one Solution is to use Twitter Cards
Maybe this thread will help you Twitter - share button, but with image

htaccess file nomenclature creating problem in opening a popup window in IE

My htaccess file nomenclature creating problem in opening a window in IE
EDITED
I have to open a colour picker which needs t be opened in popup, and I have
window.open('picker.html', null, "help=no,status=no,
scrollbars=no,resizable=no,toolbar=
no" + move + ",width=" + w + ",height=" + h + ",dependent=yes", true);
my base url goes like this:
http://www.mydoamin.com/
and the htaccess file has rewritten the above url from http://www.mydomain.com/30/
but when i wish to open the popup in IE the htaccess doesnt work for it and gives me url as http://www.mydomain.com/30/picker.html
and hence i get msg as broken link or NOT FOUND
there is no such folder called "30" the path has to be like http://www.mydomain.com/picker.html
The rewrite rule of the particular page goes like this:
RewriteRule
^30/order-vinyl-banners.html
order_form.php?id=30 [NC]
why is it happening..
please help me to track it..
If you want to show http://www.example.com/picker.html, you need to tell the open() function so. Right now you're telling it "Open the URL picker.html relative to where I'm currently at", but you want "Open picker.html relative to the root". Try this instead:
window.open('/picker.html', null,
"help=no,status=no,scrollbars=no,resizable=no,toolbar=no"
+ move + ",width=" + w + ",height=" + h + ",dependent=yes", true);

Categories