I am clutching at straws a little bit here, I want to do as the title says, when the page loads I would really love some javascript to fire off some code that checks the url, and reads the end of it. I then want to have an 'if' that says (URL ends with =en?check this radio:do nothing). the code I have attempting at fitting already is messy at best but I will show you to help you understand my lack of ability and to better explain my query:
window.onload = function(){
var url = window.location.href;
var lastPart = url.substr(url.lastIndexOf('/') + 1);
if (lastPart === "=en") {
radiobtn = document.getElementById("123456789");
radiobtn.checked = true;
}
};
Thank you guys!
This was a serious lack of understanding of the code of the code I was attempting to use.
var lastPart = url.substr(url.lastIndexOf('/') + 1);
I didnt realise that this was reading everything after the char '/'. After changing it to '=' it worked perfectly!
Sorry community!
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.