开发者

is it possible to update the query string in the browser either client or server side

开发者 https://www.devze.com 2023-03-29 00:10 出处:网络
I have a website written in asp.net MVC2 that shows random images, each image has an ID and the first image is a random one, however the url the visitor sees when viewing this image does not have the

I have a website written in asp.net MVC2 that shows random images, each image has an ID and the first image is a random one, however the url the visitor sees when viewing this image does not have the imageid. i want to make it so that when the user visits www.mydomain.com the query string will be updated to be something like www.mydomain开发者_JS百科.com/?imageid=12.

this way they can forward on what they see to others.

I dont mind if i set this with javascript, on the server side, or as a response redirect.


Not sure if this is the best way, but it would work, I suppose

window.onload = function(){
    var images = document.getElementsByTagName('img'); //get all images
    var first = images[0]; //get the first of all images
    var imgid = first.id;  //get the id of the first one
    window.location = "www.mydomain.com?imageid="+imgid;
}
0

精彩评论

暂无评论...
验证码 换一张
取 消