第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

ashx文件寫JS document.body出錯

ashx文件寫JS document.body出錯

慕哥9229398 2018-11-02 05:02:25
context.Response.ContentType = "text/plain";        context.Response.Write("function hao() {");        context.Response.Write("mss = document.createElement('div');");        context.Response.Write("document.body.appendChild(mss);");        context.Response.Write("}");        context.Response.Write("hao();"); document.body對象為空  怎么該?
查看完整描述

2 回答

?
ibeautiful

TA貢獻1993條經(jīng)驗 獲得超6個贊

你根本沒有輸出HTML結(jié)構(gòu),當然沒有body了

查看完整回答
反對 回復 2018-11-05
?
叮當貓咪

TA貢獻1776條經(jīng)驗 獲得超12個贊

這樣子一定會有問題的,這里是輸出就執(zhí)行,如果你這個ashx調(diào)用是通過ajax的話還好說,如果是其他的方式的話會存在解析先后的問題,這里的話你可以如下修改:

context.Response.ContentType = "text/plain"; 
context.Response.Write("<script type='text/javascript'>");
context.Response.Write("function hao() {");
context.Response.Write("var mss = document.createElement('div');");
context.Response.Write("document.body.appendChild(mss);");
context.Response.Write("}");
context.Response.Write("window.onload=function(){hao();}");//如果是aspx頁面中加載這個頁面,且是aspx頁面加載完成后才加載這個頁面的話哪么這句可以不要
context.Response.Write("</script>");


查看完整回答
反對 回復 2018-11-05
  • 2 回答
  • 0 關(guān)注
  • 560 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號