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;
}
精彩评论