在尝试在 $('input').on('click',function(){
// Do something
});
$window.open()
定义的窗口对象时,我遇到了相当奇怪的行为
$interval
输出
self = this
$scope.childWindow = $window.open(authService.buildAuthorizeUrl(), '_blank')
console.log $scope.childWindow
var1 = "I may not work"
self.var2 = 'I should work'
privateData.authInterval = $interval ->
console.log $scope.childWindow
console.log var1
console.log self.var2
,
1000
如您所见,第一个Window {document: document, window: Window, frameElement: null, clientInformation: Navigator, onhashchange: null…}
Window {}
I may not work
I should work
Window {}
I may not work
I should work
正在输出一个完全定义的窗口对象。 console.log $scope.childWindow
内的所有其他人仅输出$interval
。我已尝试不将{}
附加到childWindow
对象,并且我已尝试将其附加到$scope
。我也尝试过关注this示例,并遇到了相同的行为。任何人都知道为什么会这样吗?非常感谢。
JSFiddle演示:http://jsfiddle.net/U3pVM/15124/
答案 0 :(得分:1)
我在浏览器中尝试了你的代码,在$ interval函数中设置一个调试点时,一个空对象被记录在控制台中,但右边的监视检查器显示$ scope.childWindow不为空。所以你可能只能使用$ scope.childWindow。
答案 1 :(得分:0)
我知道这不应该在浏览器中工作,因为安全原因,这可以解释为什么它被“覆盖”。这个用例实际上是在Blackberry10 Cordova应用程序中。要解决此问题,您必须在<?php
include_once 'functions.php';
include_once 'db_connect.php';
header("Content-Type: application/json"); //this will tell the browser to send a json object back to client not text/html (as default)
//convert variable (array) into a JSON object
function result($var){
echo json_encode($var);
exit();
}
sec_session_start();
error_reporting(E_ALL); ini_set('display_errors', 1);
//check if surname is empty
if (isset($_POST["admin_login_but"])) {
//check if first_name is empty
if (empty($_POST["admin_name"])) {
$response = array('result'=>'fail', 'message' => 'Missing Admin Name');
result($response);
}else{
// if not empty sanitize first_name input
$admin_name = filter_input(INPUT_POST, 'admin_name', FILTER_SANITIZE_STRING);
}
//Check if email is empty and santize and validate email
if (empty($_POST['admin_email'])) {
$response = array('result'=>'fail', 'message' => 'Missing Admin Email');
result($response);
}else{
$admin_email = filter_var($_POST['admin_email'], FILTER_SANITIZE_EMAIL);
}
if (!filter_var($admin_email, FILTER_VALIDATE_EMAIL)) {
$response = array('result'=>'fail', 'message' => 'The Email is not in a Valid Email Format!');
result($response);
}
//check if register password input is empty
if (empty($_POST["admin_password"])) {
$response = array('result'=>'fail', 'message' => 'Missing Admin Password');
result($response);
} else {
//Sanitize the data passed in 'password'
$admin_password = filter_input(INPUT_POST, 'admin_password', FILTER_SANITIZE_STRING);
}
//validate the data passed in 'password'
if (!preg_match("/^.*(?=.{8,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).*$/", $admin_password)) {
$response = array('result'=>'fail', 'message' => 'Password is in the Wrong Format!');
result($response);
}
//query database
$results = mysqli_query($mysqli, "SELECT * FROM admin WHERE name = '$admin_name' AND email = '$admin_email' AND hash = '$admin_password'");
// Check if SQL query had erors
if(!$results){
$response = array('result'=>'fail', 'message' => 'sql error: ' . mysqli_error($mysqli));
result($response);
}
// If query was successfull and there are rows do this:
if (mysqli_num_rows($results)>0){
$_GET['name'] = $admin_name;
$response = array('result'=>'success', 'message' => 'User is Authenticated');
result($response);
} else {
$response = array('result'=>'fail', 'message' => 'User Authentication Failed');
result($response);
}
}
?>
中禁用网络安全性,如下所示:
config.xml
当然<access origin="*"/>
<preference name="websecurity" value="disable" />
会将所有域列入白名单。为了加强安全性,请添加您想要列入白名单的域名。