开发者

Javascript event handler load AFTER link redirection

I am trying to make a link that will load a page and then change the background image of the loaded page. The issue is that the page itself is dynamic, so it doesnt actually exist until i click the link to load it.

to be more specific i am using a e开发者_如何学C-commerce script and i want to link to each category directly and have the background of the page be different for each category.

since the pages are dynamic i cannot just ad an onload function to the page or even statically set the background.

i need the link to load the page and then change the background.... is it possible?


You can do this (at least) two ways:

1: you can add a query parameter to the link that you can read on the page that loads and then set the color based on that

2: you can hook into the onclick event of the link and set a cookie that describes the background color, and then read that cookie after pageload and set the color based on that

Both solutions can be done in a separate js module if you wish it, by for instance delegating clicks on all link that has a certain attribute set and then react to clicks on those.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜