This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
How to rewrite URL without refresh, like GitHub.com
let say I have variable in Javascript
var currentpage = 0;
my address page address is www.xyz.com/page/1
when I click somewhere and js function trigger
currentpage = 1
//Here I want to change/rewrite www.xyz.com/page/2
//Without redirecting to this page
See pushState (browser support currently limited).
You can't. You have to use the '#' or '#!' notation and pass the page number after it, then do trigger some js on load to figure out which page to display.
Related
This question already has answers here:
Last segment of URL with JavaScript
(30 answers)
Closed 5 years ago.
Currently I am on this page:
www.mysite.com/page1/
Now I want to get the last portion from that URL which is page1
I am using the following but it's showing me full URL. I need only page1
var curPage = window.location;
How can I get this?
var curPage = window.location.pathname;
See this URL for more info
How to extract the hostname portion of a URL in JavaScript
This question already has answers here:
Get the values from the "GET" parameters (JavaScript) [duplicate]
(63 answers)
Closed 6 years ago.
Is it possible to change a javascript variable through the URL?
Here's an example of the code I'm trying to modify from a website. (www.example.com)
<script type="text/javascript">
var x = 0;
</script>
I want to change the variable x from 0 to 1.
I want to do this by appending something to the URL. I'm not sure about the syntax, but I think it may be something like this:
www.example.com#javascript: var=1;
Is it possible to change variable x by only modifying the URL?
EDIT:
The duplicate question doesn't tell me how (if it's possible) to change the variable through the URL. Please let me know if that's not the case.
Related Question:
https://security.stackexchange.com/questions/134240/modify-javascript-variable-with-url-exploit
you can use:
if(window.location.href.indexOf("your_link_to_check") > -1) {
var x = 1;
}
This question already has answers here:
Get the current URL with JavaScript?
(28 answers)
Closed 8 years ago.
I have this js function
function twitterShare(){
window.open( 'http://twitter.com/intent/tweet?text='+$(".section-title h1").text() +'
'+window.location, "twitterWindow",
"height=380,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0")
return false;
}
When the twitter window opens it grabs the .section-title h1 class, but I need it to say something like this,
"Check this out here: http://currentwebsiteurl.com"
I need a text string then grab the url of the page.
Any help would be greatly appreciated.
window.location.href contains the current URL of the page.
So your function should look like this:
function twitterShare(){
window.open('http://twitter.com/intent/tweet?text=Check this out here: ' + window.location.href,
"twitterWindow", "height=380,width=660,resizable=0,toolbar=0,menubar=0,status=0,location=0,scrollbars=0")
return false;
}
You can use window.location.href. It holds the value of the current page you are on.
This question already has answers here:
Redirect faster with Greasemonkey (or similar userscript engine)?
(3 answers)
Closed 9 years ago.
i want to redirect from the first link to the other using javascript or jquery in greasemonkey
http://*.tumblr.com/post/*/*
http://$1.tumblr.com/image/$2
Use this regex
/^http:\/\/(.*).twitter.com\/post\/(.*)\/(.*)/g
Like this
var regexp = new RegExp(/^http:\/\/(.*).twitter.com\/post\/(.*)\/(.*)/g);
var results = regexp.exec(window.location.href);
To create your array, then you can
if(results){
window.location="http://"+results[1]+".twitter.com/image/"+results[2]+"/"+results[3];
}
To redirect
Live Version
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Attach File Through mailto URI
I have an HTML link like
Send Mail
I would like attach a file in the Mail Client when a User click the this link.
Is it possible in JavaScript or using jQuery, html5?
You can try MS ActiveX:
var OA = new ActiveXObject('Outlook.Application');
var OAItem = OA.CreateItem(0);
var OAItemAtms = OAItem.Attachments;
OAItemAtms.add('http://foo.com/some_image.png');
You can read more on this here - compose-and-send-e-mail-from-javascript-by-using-outlook
No.
And of course JQuery won't help since that is also Javascript.
You really need something serverside to manage this for you.