dongmi3203 2012-10-21 12:08
浏览 80
已采纳

IE9不允许使用PHP和内容类型text / css的动态样式

My plugin adds dynamic CSS to the frontpage:

function form_css() {
    header( 'Content-Type: text/css' );
    header( 'Expires: Thu, 31 Dec 2050 23:59:59 GMT' );
    header( 'Pragma: cache' );

    if ( false === ( $css = get_transient( 'mymail_form_css' ) ) ) {
        // generate CSS here
        set_transient( 'mymail_form_css', $css );
    }

    echo $css;
    die();
}

add two action hooks:

add_action('wp_ajax_my_css', 'form_css');
add_action('wp_ajax_nopriv_my_css', 'form_css');

and enqueue the style:

wp_register_style('my-css', admin_url('admin-ajax.php?action=my_css'));
wp_enqueue_style('my-css');

This works perfectly on all browsers (including IE7+8) except on IE9.

I've searched for this issue and found about the X-Content-Type-Options: nosniff header but adding header( 'X-Content-Type-Options: nosniff' )doesn't solve the problem.

Any help is kindly appreciated

  • 写回答

3条回答 默认 最新

  • douchui3933 2012-10-22 08:40
    关注

    I don't know if this helps somebody. At least for me it does:

    WordPress wraps p tags around my shortcodes and since I'm using block elements in my form (and shortcode) I've and block element inside a block element - which isn't allowed.

    Removing the surrounded p's solves the problem.

    Edit: Use the Shortcode empty paragraph fix to remove the p's

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 springboot 3.0 实现Security 6.x版本集成
  • ¥15 PHP-8.1 镜像无法用dockerfile里的CMD命令启动 只能进入容器启动,如何解决?(操作系统-ubuntu)
  • ¥15 请帮我解决一下下面六个代码
  • ¥15 关于资源监视工具的e-care有知道的嘛
  • ¥35 MIMO天线稀疏阵列排布问题
  • ¥60 用visual studio编写程序,利用间接平差求解水准网
  • ¥15 Llama如何调用shell或者Python
  • ¥20 谁能帮我挨个解读这个php语言编的代码什么意思?
  • ¥15 win10权限管理,限制普通用户使用删除功能
  • ¥15 minnio内存占用过大,内存没被回收(Windows环境)