html 目标属性并非在所有方案中都有效

gk7wooem  于 2022-11-27  发布在  其他
关注(0)|答案(1)|浏览(192)

Problem

I have tried to make a link on a pop-up user registration form open in a new browser tab, but it seems to ignore any targeting script added and keep opening the link the same tab.

Additional context:

  • The site is based on a Wordpress template
  • " " works fine in other area of the site
  1. <div class="form-group">
  2. <label for="register-terms-and-conditions">
  3. <input type="checkbox" name="terms_and_conditions" value="on" id="register-terms-and-conditions" oninvalid="setCustomValidity('Please accept the terms and conditions before proceeding')" oninput="setCustomValidity('')" required>
  4. <?php
  5. echo sprintf(wp_kses(__('I accept the <a href="https://www.google.com" target="_blank" >terms and conditions*</a>'), array('a' => array('href' => array())) ), esc_url($page_url));
  6. ?>
  7. </label>
  8. </div>

What I have tried

  1. I checked the browsers' behavior and tested with Chrome, Safari, Firefox. The results did not change.
  2. I tried testing other <a target= attributes ("blank", "_parent", "_top" to see if it is simply the problem with triggering the new tab. The results did not change.
  3. Tried onclick=" ". The result did not change.
  1. echo sprintf(wp_kses(__('I accept the <a onclick="window.open(this.href,'_blank');return false;" href="https://www.google.com" >terms and conditions*</a>'), array('a' => array('href' => array())) ), esc_url($page_url));

uemypmqf

uemypmqf1#

收到替换echo的建议。target="_blank”现在工作正常

  1. <div class="form-group">
  2. <label for="register-terms-and-conditions">
  3. <input type="checkbox" name="terms_and_conditions" value="on" id="register-terms-and-conditions" required="">
  4. Accept <a href="https://google.com" target="_blank">Terms and Conditions*</a>
  5. ?>
  6. </label>
  7. </div>

相关问题