0

我有一个价格表插件,可以在同一窗口中打开按钮链接。我想在一个新的空白窗口中打开主题。我需要在这个文件中添加什么代码?

另请注意,链接是由 wordpress 插件生成的,因此我无法在代码中手动添加 target="_blank"。

谢谢您的帮助

<div class="price-columns">
    <div id="column-skeleton" style="display:none">

        <span class="ui-icon ui-icon-carat-2-e-w column-handle"></span>
        <a href="#" class="ui-icon ui-icon-trash submitdelete deletion"></a>

        <div class="type">
            <input type="radio" value="recommend" name="price_recommend" />
            <label><?php _e('Recommend', 'pricetable') ?></label>
        </div>

        <input type="text" class="column-title" name="" placeholder="<?php _e('Title', 'pricetable') ?>" />
        <input type="text" class="column-price" name="" placeholder="<?php _e('Price', 'pricetable') ?>" />
        <input type="text" class="column-detail" name="" placeholder="<?php _e('Detail', 'pricetable') ?>" />
        <input type="text" class="column-url" name="" placeholder="<?php _e('Button URL', 'pricetable') ?>" />
        <input type="text" class="column-button" name="" placeholder="<?php _e('Button Text', 'pricetable') ?>" />

        <h4><a href="#" class="addfeature"><?php _e('Add', 'pricetable') ?></a><?php _e('Features', 'pricetable') ?></h4>
        <div class="feautres">
            <div class="feature">
                <span class="ui-icon ui-icon-carat-2-n-s feature-handle"></span>
                <a href="#" class="ui-icon ui-icon-trash submitdelete deletion"></a>

                <div><input type="text" class="feature-title" placeholder="<?php _e('Title', 'pricetable') ?>"/></div>
                <div><input type="text" class="feature-sub" placeholder="<?php _e('Sub title', 'pricetable') ?>" /></div>
            </div>
        </div>
    </div>

    <?php // Existing columns of the price table ?>
    <?php foreach($table as $i => $column) : ?>
        <div class="column">
            <span class="ui-icon ui-icon-carat-2-e-w column-handle"></span>
            <a href="#" class="ui-icon ui-icon-trash submitdelete deletion"></a>

            <div class="type">
                <input type="radio" name="price_recommend" id="price_recommend_<?php print $i ?>" value="<?php print $i ?>" <?php if(isset($column['featured']) && $column['featured'] === 'true') print 'checked="true"'; ?> />
                <label for="price_recommend_<?php print $i ?>"><?php _e('Recommend', 'pricetable') ?></label>
            </div>

            <input type="text" class="column-title" name="price_<?php print $i ?>_title" value="<?php @esc_attr_e($column['title']) ?>" placeholder="<?php _e('Title', 'pricetable') ?>" />
            <input type="text" class="column-price" name="price_<?php print $i ?>_price" value="<?php @esc_attr_e($column['price']) ?>" placeholder="<?php _e('Price', 'pricetable') ?>" />
            <input type="text" class="column-detail" name="price_<?php print $i ?>_detail" value="<?php @esc_attr_e($column['detail']) ?>" placeholder="<?php _e('Detail', 'pricetable') ?>" />
            <input type="text" class="column-url" name="price_<?php print $i ?>_url" value="<?php @esc_attr_e($column['url']) ?>" placeholder="<?php _e('Button URL', 'pricetable') ?>" />
            <input type="text" class="column-button" name="price_<?php print $i ?>_button" value="<?php @esc_attr_e($column['button']) ?>" placeholder="<?php _e('Button Text', 'pricetable') ?>" />

            <h4><a href="#" class="addfeature"><?php _e('Add', 'pricetable') ?></a><?php _e('Features', 'pricetable') ?></h4>
            <div class="feautres">
                <?php if(isset($column['features'])) : foreach($column['features'] as $j => $feature) : ?>
                    <div class="feature">
                        <span class="ui-icon ui-icon-carat-2-n-s feature-handle"></span>
                        <a href="#" class="ui-icon ui-icon-trash submitdelete deletion"></a>

                        <div><input type="text" class="feature-title" name="price_<?php print $i ?>_feature_<?php print $j ?>_title" value="<?php esc_attr_e($feature['title']) ?>" placeholder="<?php _e('Title', 'pricetable') ?>"/></div>
                        <div><input type="text" class="feature-sub" name="price_<?php print $i ?>_feature_<?php print $j ?>_sub" value="<?php esc_attr_e($feature['sub']) ?>" placeholder="<?php _e('Sub title', 'pricetable') ?>" /></div>
                    </div>
                <?php endforeach; endif; ?>
            </div>
        </div>
    <?php endforeach ?>

    <div class="column addnew"><?php _e('Add Column', 'pricetable') ?></div>
    <div class="clear"></div>
</div>
4

4 回答 4

3

您可以target="_blank"<a>标签中使用。

于 2012-04-23T18:22:31.433 回答
2

好的,如果您的链接是由 wordpress 生成的,您可以考虑在页面加载后动态添加目标属性。Use the following script after page load or document ready

<head>
<script type="text/javascript">

function add_target()
{
   // Find all the anchors you want to modify
   var anchors = document..getElementsByTagName('a'),
   i = anchors.length;

   // Add the target to each one
   while(i--) anchors[i].target = "_blank";
}

</script>
</head>

<body onload="add_target()">
/* your body */
</body>
于 2012-04-23T18:35:59.500 回答
0

添加到每个 Target="_blank" 就是这样。

于 2012-04-23T18:23:10.477 回答
0

<a href="your_url" target="_blank">link</a>在您的代码中使用。

于 2012-04-23T18:26:02.547 回答