起步软件技术论坛
搜索
 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1576|回复: 5

[处理中2] 苹果手机报错

[复制链接]

134

主题

417

帖子

844

积分

高级会员

Rank: 4

积分
844
QQ
发表于 2016-4-28 16:27:19 | 显示全部楼层 |阅读模式
DOM Exception 18:An attempt was made to break through the security of the user agent这个是错

用Wex5打包的应用,在使用的过程中为什么报上面的错,最重要的是,有些页面不报错,报错的页面都有关于法律的信息,难道是苹果手机检测到关于安全的信息,然后就报错吗??

12

主题

2627

帖子

2866

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
2866
发表于 2016-4-28 16:31:39 | 显示全部楼层
回复 支持 反对

使用道具 举报

134

主题

417

帖子

844

积分

高级会员

Rank: 4

积分
844
QQ
 楼主| 发表于 2016-4-28 18:57:47 | 显示全部楼层
hecr 发表于 2016-4-28 16:31
有解决方案
参考: http://doc.wex5.com/wex5-app-question-list-0002/

这个我试过了,两种方法都试了,还是报那个错,怎么办?
回复 支持 反对

使用道具 举报

12

主题

2627

帖子

2866

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
2866
发表于 2016-4-29 09:03:06 | 显示全部楼层
把你改过的router.js发来看看;
另: 你使用的模式几打包? 以及打包时"Web路径"是什么?
回复 支持 反对

使用道具 举报

134

主题

417

帖子

844

积分

高级会员

Rank: 4

积分
844
QQ
 楼主| 发表于 2016-5-3 16:39:59 | 显示全部楼层
本帖最后由 我是猿 于 2016-5-3 16:46 编辑
hecr 发表于 2016-4-29 09:03
把你改过的router.js发来看看;
另: 你使用的模式几打包? 以及打包时"Web路径"是什么? ...

我发不了文件,只能全部贴上去了。用模式2打包,web路径是http://n.andtedh.net:8090

/*!
* WeX5 v3 (http://www.justep.com)
* Copyright 2015 Justep, Inc.
* Licensed under Apache License, Version 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
*/
define(function(require){
        var $=require('jquery'),
                Object = require("$UI/system/lib/base/object"),
                Observable = require("$UI/system/lib/base/observable"),
                URL = require('$UI/system/lib/base/url'),
                Browser = require('$UI/system/lib/base/browser'),
                _history = window.history,
                HashbangParser = require('./hashbangParser'),
                _lastChangeTimeStamp = new Date().getTime();
               
        
        var HashbangToken = "#!",
                StateSeriesSplitToken = "!",
                LeftBarcketToken = "(",
                RightBarcketToken = ")",
                SegmentSplitToken = "/";
        
        function ignoreVLS(url){
                return URL._removeVLS(url);
        };
        
        
        function convertToOldUrl(){
                var oldUrl = new URL(window.__justep.__ResourceEngine.url);
                var path = oldUrl.getPathname();
                var currentUrl = new URL(location.href);
                var search = currentUrl.getSearch();
                var hash = currentUrl.getHash();
                return path + search + hash;
        };
        
        
        
        
        
        
        var isSimulator = false;
        try{
                isSimulator = window.parent && window.parent.getOSName;
        }catch(err){
        }
        
        var Router = Object.extend({
                mixin:Observable,
                constructor: function(){
                        this.callParent();
                        Observable.prototype.constructor.call(this);
                        this.checkRedirectParam();
                        this.interceptLinkHash();
                        this.polyfillStateApi();
                        this.originUrl = location.href;
                        this.ignoreVls();
                        this.subscribeState();
                }
        });
        
        
        Router.prototype.checkRedirectParam = function(){
                var currentUrl = new URL(location.href);
                if(currentUrl.getParam('_shareHash')){
                        var _shareHash = currentUrl.getParam('_shareHash');
                        currentUrl.setHash(_shareHash);
                        currentUrl.removeParam('_shareHash');
                        this.publishState({
                                isReplace:true,
                                hashbang:currentUrl.toString()
                        });
                }
        };
        
        Router.prototype.polyfillStateApi = function(){
                if(typeof _history.pushState != 'function'){
                        _history.pushState = function(){};
                        _history.replaceState = function(){};
                }
        };
        
        Router.prototype.revertVls = function(){
                if(!Browser.isWeChat && !isSimulator){
                        var url = convertToOldUrl();
                        this.publishState({
                                isIgnoreVersionPublish:true,
                                isReplace:true,
                                hashbang:url
                        });
                }        
        };
        
        Router.prototype.ignoreVls = function(){
                if(!Browser.isWeChat && !isSimulator){
                        var ignoreVersionUrl = ignoreVLS(location.pathname + location.search) + location.hash;
                        this.publishState({
                                isIgnoreVersionPublish:true,
                                isReplace:true,
                                hashbang:ignoreVersionUrl
                        });
                }
        };
        
               
        Router.prototype.interceptLinkHash = function(){
                var self = this;
                $(document).on('click.routeState','a',function(event){
                        var href = $(event.currentTarget).attr('href');
                        if(href && href.indexOf('#!') == 0){
                                event.preventDefault();
                                //debugger;
                                var bindingContext = justep.Bind.contextFor(event.target);
                                if(bindingContext){
                                        var $model = bindingContext.$model;
                                        if($model){
                                                $model.fireEvent('onRouteStatePublish',{
                                                        hashbang: href,
                                                        isReplace:false
                                                });
                                                $model.postMessage({
                                                        type:"routeState",
                                                        newUrl:href
                                                });
                                        }
                                }
                        }else if(href && href == '#'){
                                event.preventDefault();
                        }
                });
        };
        
        
        Router.prototype.subscribeState = function(){
                $(window).on('hashchange',$.proxy(function(event){
                        _lastChangeTimeStamp = new Date().getTime();
                        var e = event.originalEvent;
                        var newUrl = e.newURL;
                        var oldUrl = e.oldURL;
                        if(newUrl == undefined){
                                newUrl = location.href;
                        }
                        this.dispatchChange(newUrl,oldUrl);
                },this));
        };
        
        Router.prototype.dispatchChange = function(newUrl,oldUrl){
                this.rootModel.postMessage({
                        type:"routeState",
                        oldUrlldUrl,
                        newUrl:newUrl
                });
        };
        
        Router.prototype.publishState = function(event){
                var currentTimeStamp = new Date().getTime();
                var isReplace = event.isReplace;
                if(currentTimeStamp - _lastChangeTimeStamp < 800){
                        isReplace = true;
                }
                var hashbang = event.hashbang;
                if(hashbang == "" || hashbang === HashbangToken){
                        if(typeof justep.Portal.getPortal() !== "undefined"){
                                return;
                        }else{
                                hashbang = "";
                        }
                }
                if(isReplace){
                        this.publishState._lastState = hashbang;
                         try{_history.replaceState(null,null,hashbang);}catch(e){console.log(e);}
                }else{
                        if(this.publishState._lastState !== hashbang){
                                this.publishState._lastState = hashbang;
                                _lastChangeTimeStamp = currentTimeStamp;
                                _history.pushState(null,null,hashbang);
                        }
                }
        };
        
        Router.prototype.setRootModel = function(model){
                var self = this;
                if(typeof this.rootModel == 'undefined'){
                        this.rootModel = model;
                        this.rootModel.on('onRouteStatePublish',function(event){
                                this.publishState(event);
                        },this);
                        var originHref = location.href;
                        //第一次进来理解url
                        this.rootModel.on('onLoaded',function(event){
                                self.dispatchChange(originHref,'');
                        },this);
                }
        };
    return new Router();
   
});

这个问题非常急,麻烦您帮忙解决一下了
回复 支持 反对

使用道具 举报

12

主题

2627

帖子

2866

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
2866
发表于 2016-5-10 13:18:11 | 显示全部楼层
楼主, 你的代码替换不全, 应该有两个地方  _history.pushState(null,null,hashbang); 需要替换, 你现在只替换了一个地方的.

另, 替换完代码后, 需要执行
第二步:执行%JUSTEP_HOME%/tools/dist/dist.bat批处理合并资源;
第三步:重新启动WeX5开发工具即Studio;
第四步:重新打包App;
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|X3技术论坛|Justep Inc.    

GMT+8, 2024-6-2 12:37 , Processed in 0.120179 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表