2

I'm using this JS code to get the page url, title and send them to the server to store them in a database, like a button you bookmarked in your browser toolbar and click it on any website you have open and it will get the website's URL and TITLE.

However this code is working great BUT it's not working with (https) url

javascript:(function(){var jsScript=document.createElement('script');
jsScript.setAttribute('type','text/javascript');
jsScript.setAttribute('src', 'bookmark.php?url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title));
document.getElementsByTagName('head')[0].appendChild(jsScript);
})();

It's working good with all url's Except (https) links like
https://facebook.com
https://google.com

It's not working at all with these kind of links.

Any improvements that could make it work with https links?

Thanks in advance.

10

2 Answers 2

1

You`ll always have problems getting HTTPS URL, unless the server your are sending data is also HTTPS. Your server may need SSL certificate in order to complete the task. However, facebook, google still have http:// access enabled, although this URL is converted automatically to https://, so you might be able to fetch some of those requests.

Edit: This is because so called Cross-Origin Resource Sharing (CORS).

Sign up to request clarification or add additional context in comments.

Comments

0

use your all personal js. don't take from any external link js and css. if you have all css and js in your project folder then it will work properly. thank you

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.