2

我正在尝试在 android webview 上运行这个 javascript:

function date_time(id)
{
        date = new Date;
        year = date.getFullYear();
        month = date.getMonth();
        months = new Array('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
        d = date.getDate();
        day = date.getDay();
        days = new Array('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday');
        h = date.getHours();
        if(h<10)
        {
                h = "0"+h;
        }
        m = date.getMinutes();
        if(m<10)
        {
                m = "0"+m;
        }
        s = date.getSeconds();
        if(s<10)
        {
                s = "0"+s;
        }
        <!-- ''+days[day]+' '+months[month]+' '+d+' '+year+' '+h+':'+m+':'+ -->
        result = s;
        document.getElementById(id).innerHTML = result;
        setTimeout('date_time("'+id+'");','1000');
        return true;
}

HTML部分为:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>Display Date and Time in Javascript</title>
        <script type="text/javascript" src="date_time.js"></script>
    </head>
    <body>
            <span id="date_time"></span>
            <script type="text/javascript">window.onload = date_time('date_time');</script>
    </body>
</html>

但是,logcat 显示以下错误:

07-18 16:40:54.179: I/DEBUG(7215): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
07-18 16:40:54.179: I/DEBUG(7215): Build fingerprint: 'motorola/mb526_umts/mb526:4.1.2/JZO54K/20130511:user/release-keys'
07-18 16:40:54.179: I/DEBUG(7215): pid: 7267, tid: 7267, name: UNKNOWN  
07-18 16:40:54.179: I/DEBUG(7215): signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 4b189684
07-18 16:40:54.570: I/DEBUG(7215):     r0 4b189684  r1 00000000  r2 ffffffff  r3 4b189684
07-18 16:40:54.570: I/DEBUG(7215):     r4 2a21a188  r5 4b189680  r6 00000000  r7 44c79ce8
07-18 16:40:54.570: I/DEBUG(7215):     r8 2a2797d8  r9 44c79cd4  sl 2a00ba30  fp beea569c
07-18 16:40:54.570: I/DEBUG(7215):     ip 40345dd8  sp beea55d8  lr 40271338  pc 4009a25c  cpsr 200f0050
07-18 16:40:54.570: I/DEBUG(7215):     d0  67756265643a6467  d1  c0668000bc3e8365
07-18 16:40:54.570: I/DEBUG(7215):     d2  c02b800000000072  d3  44f36c4800000064
07-18 16:40:54.570: I/DEBUG(7215):     d4  0000000100000045  d5  006e006500000002
07-18 16:40:54.570: I/DEBUG(7215):     d6  0000000200000000  d7  0000000000530055
07-18 16:40:54.570: I/DEBUG(7215):     d8  0000000000000000  d9  4075a40000000000
07-18 16:40:54.570: I/DEBUG(7215):     d10 4066800000000000  d11 0000000000000000
07-18 16:40:54.570: I/DEBUG(7215):     d12 0000000000000000  d13 0000000000000000
07-18 16:40:54.570: I/DEBUG(7215):     d14 0000000000000000  d15 0000000000000000
07-18 16:40:54.570: I/DEBUG(7215):     d16 7fffffffffffffff  d17 7fffffffffffffff
07-18 16:40:54.570: I/DEBUG(7215):     d18 0000000000000000  d19 bc0a42cc192d5632
07-18 16:40:54.570: I/DEBUG(7215):     d20 4000000000000000  d21 be23e4f5df600000
07-18 16:40:54.570: I/DEBUG(7215):     d22 bf6700ad4f2e261e  d23 3f11566a75de22e0
07-18 16:40:54.577: I/DEBUG(7215):     d24 bf66c16bcf2488c9  d25 3fc555552658226f
07-18 16:40:54.577: I/DEBUG(7215):     d26 3fd55559bbdd31c6  d27 bf70101000000000
07-18 16:40:54.577: I/DEBUG(7215):     d28 3fdb6dbc40ea5c02  d29 3fe33336ab4b2dfc
07-18 16:40:54.577: I/DEBUG(7215):     d30 3fffefef00000000  d31 0000000000000000
07-18 16:40:54.577: I/DEBUG(7215):     scr 80000010
07-18 16:40:54.601: I/DEBUG(7215): backtrace:
07-18 16:40:54.601: I/DEBUG(7215):     #00  pc 0000525c  /system/lib/libcutils.so (android_atomic_dec+8)
07-18 16:40:54.601: I/DEBUG(7215):     #01  pc 0007b334  /system/lib/libskia.so (SkPaint::~SkPaint()+56)
07-18 16:40:54.601: I/DEBUG(7215):     #02  pc 000853a4  /system/lib/libskia.so (SkPicturePlayback::~SkPicturePlayback()+152)
07-18 16:40:54.601: I/DEBUG(7215):     #03  pc 0008550c  /system/lib/libskia.so (SkPicturePlayback::~SkPicturePlayback()+8)
07-18 16:40:54.601: I/DEBUG(7215):     #04  pc 000848a0  /system/lib/libskia.so (SkPicture::~SkPicture()+76)
07-18 16:40:54.601: I/DEBUG(7215):     #05  pc 000848e4  /system/lib/libskia.so (SkPicture::~SkPicture()+8)
07-18 16:40:54.601: I/DEBUG(7215):     #06  pc 0038df3d  /system/lib/libwebcore.so
07-18 16:40:54.601: I/DEBUG(7215):     #07  pc 0038dfa9  /system/lib/libwebcore.so
07-18 16:40:54.601: I/DEBUG(7215):     #08  pc 0038dfd1  /system/lib/libwebcore.so
07-18 16:40:54.601: I/DEBUG(7215):     #09  pc 0018e505  /system/lib/libwebcore.so
07-18 16:40:54.601: I/DEBUG(7215):     #10  pc 0038c34f  /system/lib/libwebcore.so (WebCore::LayerAndroid::~LayerAndroid()+58)
07-18 16:40:54.601: I/DEBUG(7215):     #11  pc 00388b69  /system/lib/libwebcore.so
07-18 16:40:54.601: I/DEBUG(7215):     #12  pc 00388ba9  /system/lib/libwebcore.so
07-18 16:40:54.601: I/DEBUG(7215):     #13  pc 0018e505  /system/lib/libwebcore.so
07-18 16:40:54.609: I/DEBUG(7215):     #14  pc 002838bd  /system/lib/libwebcore.so
07-18 16:40:54.609: I/DEBUG(7215):     #15  pc 0001e0b0  /system/lib/libdvm.so (dvmPlatformInvoke+112)
07-18 16:40:54.609: I/DEBUG(7215):     #16  pc 0004d0cf  /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const*, JValue*, Method const*, Thread*)+390)
07-18 16:40:54.609: I/DEBUG(7215):     #17  pc 000274e0  /system/lib/libdvm.so
07-18 16:40:54.609: I/DEBUG(7215):     #18  pc 0002bdc4  /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+180)
07-18 16:40:54.609: I/DEBUG(7215):     #19  pc 0005faf7  /system/lib/libdvm.so (dvmInvokeMethod(Object*, Method const*, ArrayObject*, ArrayObject*, ClassObject*, bool)+374)
07-18 16:40:54.609: I/DEBUG(7215):     #20  pc 000670e9  /system/lib/libdvm.so
07-18 16:40:54.609: I/DEBUG(7215):     #21  pc 000274e0  /system/lib/libdvm.so
07-18 16:40:54.609: I/DEBUG(7215):     #22  pc 0002bdc4  /system/lib/libdvm.so (dvmInterpret(Thread*, Method const*, JValue*)+180)
07-18 16:40:54.609: I/DEBUG(7215):     #23  pc 0005f831  /system/lib/libdvm.so (dvmCallMethodV(Thread*, Method const*, Object*, bool, JValue*, std::__va_list)+272)
07-18 16:40:54.609: I/DEBUG(7215):     #24  pc 00049727  /system/lib/libdvm.so
07-18 16:40:54.609: I/DEBUG(7215):     #25  pc 000477ad  /system/lib/libandroid_runtime.so
07-18 16:40:54.609: I/DEBUG(7215):     #26  pc 0004828f  /system/lib/libandroid_runtime.so (android::AndroidRuntime::start(char const*, char const*)+390)
07-18 16:40:54.609: I/DEBUG(7215):     #27  pc 00000dcf  /system/bin/app_process
07-18 16:40:54.609: I/DEBUG(7215): stack:
07-18 16:40:54.609: I/DEBUG(7215):          beea5598  44c79ce8  
07-18 16:40:54.609: I/DEBUG(7215):          beea559c  4003f64d  /system/lib/libc.so (dlfree+56)
07-18 16:40:54.609: I/DEBUG(7215):          beea55a0  4003f615  /system/lib/libc.so (dlfree)
07-18 16:40:54.609: I/DEBUG(7215):          beea55a4  2a26fb44  
07-18 16:40:54.609: I/DEBUG(7215):          beea55a8  00001000  
07-18 16:40:54.609: I/DEBUG(7215):          beea55ac  2a25a4f8  
07-18 16:40:54.609: I/DEBUG(7215):          beea55b0  00000000  
07-18 16:40:54.609: I/DEBUG(7215):          beea55b4  00000000  
07-18 16:40:54.609: I/DEBUG(7215):          beea55b8  44c79ce8  
07-18 16:40:54.609: I/DEBUG(7215):          beea55bc  4003f64d  /system/lib/libc.so (dlfree+56)
07-18 16:40:54.609: I/DEBUG(7215):          beea55c0  4003f615  /system/lib/libc.so (dlfree)
07-18 16:40:54.609: I/DEBUG(7215):          beea55c4  2a25a4f8  
07-18 16:40:54.609: I/DEBUG(7215):          beea55c8  00000000  
07-18 16:40:54.609: I/DEBUG(7215):          beea55cc  00000000  
07-18 16:40:54.609: I/DEBUG(7215):          beea55d0  df0027ad  
07-18 16:40:54.609: I/DEBUG(7215):          beea55d4  00000000  
07-18 16:40:54.609: I/DEBUG(7215):     #00  beea55d8  00000002  
07-18 16:40:54.609: I/DEBUG(7215):          ........  ........
07-18 16:40:54.609: I/DEBUG(7215):     #01  beea55d8  00000002  
07-18 16:40:54.609: I/DEBUG(7215):          beea55dc  2a25a4f8  
07-18 16:40:54.609: I/DEBUG(7215):          beea55e0  2a21a188  
07-18 16:40:54.609: I/DEBUG(7215):          beea55e4  4027b3a8  /system/lib/libskia.so (SkPicturePlayback::~SkPicturePlayback()+156)
07-18 16:40:54.609: I/DEBUG(7215):     #02  beea55e8  2a25a4f8  
07-18 16:40:54.609: I/DEBUG(7215):          beea55ec  00000000  
07-18 16:40:54.609: I/DEBUG(7215):          beea55f0  00000000  
07-18 16:40:54.609: I/DEBUG(7215):          beea55f4  4027b510  /system/lib/libskia.so (SkPicturePlayback::~SkPicturePlayback()+12)
07-18 16:40:54.632: I/DEBUG(7215): memory near r0:
07-18 16:40:54.632: I/DEBUG(7215):     4b189664 00000000 00000000 00000000 00000000  ................
07-18 16:40:54.632: I/DEBUG(7215):     4b189674 00000000 00000000 00000000 00000000  ................
07-18 16:40:54.632: I/DEBUG(7215):     4b189684 00000000 00000000 00000000 00000000  ................
07-18 16:40:54.632: I/DEBUG(7215):     4b189694 00000000 00000000 00000000 00000000  ................
07-18 16:40:54.632: I/DEBUG(7215):     4b1896a4 00000000 00000000 00000000 00000000  ................
07-18 16:40:54.632: I/DEBUG(7215): memory near r3:
07-18 16:40:54.632: I/DEBUG(7215):     4b189664 00000000 00000000 00000000 00000000  ................
07-18 16:40:54.632: I/DEBUG(7215):     4b189674 00000000 00000000 00000000 00000000  ................
07-18 16:40:54.632: I/DEBUG(7215):     4b189684 00000000 00000000 00000000 00000000  ................
07-18 16:40:54.632: I/DEBUG(7215):     4b189694 00000000 00000000 00000000 00000000  ................
07-18 16:40:54.632: I/DEBUG(7215):     4b1896a4 00000000 00000000 00000000 00000000  ................
07-18 16:40:54.632: I/DEBUG(7215): memory near r4:
07-18 16:40:54.632: I/DEBUG(7215):     2a21a168 00000000 00000000 ffffffff 00000000  ................
07-18 16:40:54.632: I/DEBUG(7215):     2a21a178 40800000 04000006 00000000 00000007  ...@............
07-18 16:40:54.632: I/DEBUG(7215):     2a21a188 00000000 00000000 00000000 4b189680  ...............K
07-18 16:40:54.632: I/DEBUG(7215):     2a21a198 4b189680 00000000 00000000 00000000  ...K............
07-18 16:40:54.632: I/DEBUG(7215):     2a21a1a8 00000000 00000000 00000000 00000000  ................
07-18 16:40:54.632: I/DEBUG(7215): memory near r5:
07-18 16:40:54.632: I/DEBUG(7215):     4b189660 00000000 00000000 00000000 00000000  ................
07-18 16:40:54.632: I/DEBUG(7215):     4b189670 00000000 00000000 00000000 00000000  ................
07-18 16:40:54.632: I/DEBUG(7215):     4b189680 00000000 00000000 00000000 00000000  ................
07-18 16:40:54.640: I/DEBUG(7215):     4b189690 00000000 00000000 00000000 00000000  ................
07-18 16:40:54.640: I/DEBUG(7215):     4b1896a0 00000000 00000000 00000000 00000000  ................
07-18 16:40:54.640: I/DEBUG(7215): memory near r7:
07-18 16:40:54.640: I/DEBUG(7215):     44c79cc8 00000006 00000000 3da00019 2a1445a0  ...........=.E.*
07-18 16:40:54.640: I/DEBUG(7215):     44c79cd8 2a263c30 00000000 00000000 00000000  0<&*............
07-18 16:40:54.640: I/DEBUG(7215):     44c79ce8 44c79d3c 4671a788 44e416f8 4671a4ae  <..D..qF...D..qF
07-18 16:40:54.640: I/DEBUG(7215):     44c79cf8 00000000 40e72ce8 2a1445a0 2a263c30  .....,.@.E.*0<&*
07-18 16:40:54.640: I/DEBUG(7215):     44c79d08 00000000 00000000 00000000 44e36b98  .............k.D
07-18 16:40:54.640: I/DEBUG(7215): memory near r8:
07-18 16:40:54.640: I/DEBUG(7215):     2a2797b8 00000000 2a33cbe0 00000008 00000008  ......3*........
07-18 16:40:54.640: I/DEBUG(7215):     2a2797c8 0000001b 00000013 00000000 00000000  ................
07-18 16:40:54.640: I/DEBUG(7215):     2a2797d8 00000000 00000000 00000000 00000000  ................
07-18 16:40:54.640: I/DEBUG(7215):     2a2797e8 2a279858 00000000 2a279804 2a27982c  X.'*......'*,.'*
07-18 16:40:54.640: I/DEBUG(7215):     2a2797f8 00000000 00000000 2a21e810 3f800000  ..........!*...?
07-18 16:40:54.640: I/DEBUG(7215): memory near r9:
07-18 16:40:54.640: I/DEBUG(7215):     44c79cb4 44c79d04 4649e10e 44c79cfc 4671a4ae  ...D..IF...D..qF
07-18 16:40:54.640: I/DEBUG(7215):     44c79cc4 44e3dd68 00000006 00000000 3da00019  h..D...........=
07-18 16:40:54.640: I/DEBUG(7215):     44c79cd4 2a1445a0 2a263c30 00000000 00000000  .E.*0<&*........
07-18 16:40:54.640: I/DEBUG(7215):     44c79ce4 00000000 44c79d3c 4671a788 44e416f8  ....<..D..qF...D
07-18 16:40:54.640: I/DEBUG(7215):     44c79cf4 4671a4ae 00000000 40e72ce8 2a1445a0  ..qF.....,.@.E.*
07-18 16:40:54.640: I/DEBUG(7215): memory near sl:
07-18 16:40:54.640: I/DEBUG(7215):     2a00ba10 00000000 00000000 00000000 00000453  ............S...
07-18 16:40:54.640: I/DEBUG(7215):     2a00ba20 46717908 44c79cd0 44e416f8 46d85000  .yqF...D...D.P.F
07-18 16:40:54.640: I/DEBUG(7215):     2a00ba30 00000000 00000000 beea57b0 00000000  .........W......
07-18 16:40:54.640: I/DEBUG(7215):     2a00ba40 beea57e4 00000001 00000000 4074a240  .W..........@.t@
07-18 16:40:54.640: I/DEBUG(7215):     2a00ba50 00000000 00000000 443fde70 44c74300  ........p.?D.C.D
07-18 16:40:54.640: I/DEBUG(7215): memory near fp:
07-18 16:40:54.640: I/DEBUG(7215):     beea567c 00000000 00000000 40774b0b 44c79cd0  .........Kw@...D
07-18 16:40:54.640: I/DEBUG(7215):     beea568c 00000001 40e72ce8 00000000 40c19220  .....,.@.... ..@
07-18 16:40:54.640: I/DEBUG(7215):     beea569c 407790d3 44c79cd0 469ae2df 490b6889  ..w@...D...F.h.I
07-18 16:40:54.640: I/DEBUG(7215):     beea56ac 2a00ba30 00000000 00000000 407d66ac  0..*.........f}@
07-18 16:40:54.640: I/DEBUG(7215):     beea56bc 40073b04 00000004 2a00ba20 ffffbfff  .;.@.... ..*....
07-18 16:40:54.640: I/DEBUG(7215): memory near ip:
07-18 16:40:54.640: I/DEBUG(7215):     40345db8 00000000 00000000 40038880 400381ec  ...........@...@
07-18 16:40:54.640: I/DEBUG(7215):     40345dc8 400382f8 4007b8f7 4007b8e9 40037d68  ...@...@...@h}.@
07-18 16:40:54.640: I/DEBUG(7215):     40345dd8 4009a254 4009a238 40041080 4008c918  T..@8..@...@...@
07-18 16:40:54.640: I/DEBUG(7215):     40345de8 4008a5f8 40038821 4007b901 40038948  ...@!..@...@H..@
07-18 16:40:54.648: I/DEBUG(7215):     40345df8 40038a24 40038928 40041001 40039b34  $..@(..@...@4..@
07-18 16:40:54.648: I/DEBUG(7215): memory near sp:
07-18 16:40:54.648: I/DEBUG(7215):     beea55b8 44c79ce8 4003f64d 4003f615 2a25a4f8  ...DM..@...@..%*
07-18 16:40:54.648: I/DEBUG(7215):     beea55c8 00000000 00000000 df0027ad 00000000  .........'......
07-18 16:40:54.648: I/DEBUG(7215):     beea55d8 00000002 2a25a4f8 2a21a188 4027b3a8  ......%*..!*..'@
07-18 16:40:54.648: I/DEBUG(7215):     beea55e8 2a25a4f8 00000000 00000000 4027b510  ..%*..........'@
07-18 16:40:54.648: I/DEBUG(7215):     beea55f8 2a33cbe0 4027a8a4 4027a8dc 2a33cbe0  ..3*..'@..'@..3*
07-18 16:40:54.648: I/DEBUG(7215): code around pc:
07-18 16:40:54.648: I/DEBUG(7215):     4009a23c e1930f9f e2801001 e1832f91 e3520000  ........./....R.
07-18 16:40:54.648: I/DEBUG(7215):     4009a24c 1afffffa e12fff1e e1a03000 e3e02000  ....../..0... ..
07-18 16:40:54.648: I/DEBUG(7215):     4009a25c e1930f9f e080c002 e1831f9c e3510000  ..............Q.
07-18 16:40:54.648: I/DEBUG(7215):     4009a26c 1afffffa e12fff1e e1a03000 e1910f9f  ....../..0......
07-18 16:40:54.648: I/DEBUG(7215):     4009a27c e000c003 e1812f9c e3520000 1afffffa  ...../....R.....
07-18 16:40:54.648: I/DEBUG(7215): code around lr:
07-18 16:40:54.648: I/DEBUG(7215):     40271318 e3500001 e1a03000 0a000072 e5945010  ..P..0..r....P..
07-18 16:40:54.648: I/DEBUG(7215):     40271328 e3550000 0a000004 e2850004 ebff073f  ..U.........?...
07-18 16:40:54.648: I/DEBUG(7215):     40271338 e3500001 e1a03000 0a000064 e5945014  ..P..0..d....P..
07-18 16:40:54.648: I/DEBUG(7215):     40271348 e3550000 0a000004 e2850004 ebff0737  ..U.........7...
07-18 16:40:54.648: I/DEBUG(7215):     40271358 e3500001 e1a03000 0a000056 e5945018  ..P..0..V....P..
07-18 16:40:54.648: I/DEBUG(7215): memory map around fault addr 4b189684:
07-18 16:40:54.648: I/DEBUG(7215):     4af01000-4b000000 
07-18 16:40:54.648: I/DEBUG(7215):     4b000000-4b300000 
07-18 16:40:54.648: I/DEBUG(7215):     4b300000-4b400000 
07-18 16:40:54.960: I/BootReceiver(1564): Copying /data/tombstones/tombstone_05 to DropBox (SYSTEM_TOMBSTONE)
07-18 16:40:55.046: D/CameraHal(1243): stopPreview

它看起来像一个段错误:

07-18 17:06:46.538: A/libc(7412): Fatal signal 11 (SIGSEGV) at 0x00000000 (code=1), thread 7470 (Thread-442)

仅刷新类型 javascript 会出现错误(上面的脚本显示当前时间),否则代码可以正常工作。请帮忙。

4

0 回答 0