开发者

How to add javascript to page on login and logout in Drupal 6

I'm working on a module and am trying to add some javascript to the next page a user sees after logging in or out. Calling drupal_add_js() on hook_user (op == login) doesn't seem to work; I'm assuming this is because drup开发者_Python百科al_goto is called after the login is completed and a fresh page request is initiated.

I've considered using hook_user to set session variables which I can then respond to on the next page load but that seems somewhat fragile. Any suggestions?


If you want something to be carried over to a new page you only have a few options:

  • Alter the url.
  • Store in the database.
  • Store in session.

Altering the url, would probably be quite hard and messy. Storing in the session or database is basically the same thing. So you would probably want to use the Drupal session system instead of making your own.

You could add something in the session and then in hook_init check for it and if it's there add the js and delete it from the session.

I don't think you will find a much better solution, though it would be nice if there were.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜