2014-01-09 28 views
0

我在另一个页面中有一个drupal proyect作为iframe,我想向登录提交按钮添加一个属性,将顶部url重定向到像这样的自定义url :在Drupal 7中添加一个“onclick”属性来登录提交按钮

top.location.href = 'somepage.html'; 

我想这一点:

function hook_form_alter(&$form, &$form_state, $form_id){ 
    if($form_id == 'user_login_block'){ 
     $form['actions']['submit']['#attributes'] = array('onclick' => "top.location.href = 'somepage.html';"); 
    } 
    } 

我敢肯定的是,$form_iduser_login_form,但什么都没有发生。

+0

你能提供的jsfiddle? – Kallewallex

回答

1

你需要从

$form['actions']['submit']['#attributes'] = array('onclick' => "top.location.href = 'somepage.html';"); 

行更改为

$form['actions']['submit']['#attributes'] = array('onclick' => "javascript: top.location.href = 'somepage.html';");