getting an error "ns_error_unknown_protocol

我与影子孤独终老i 提交于 2019-12-11 15:04:43

问题


im getting an error "ns_error_unknown_protocol" when i run this code in firefox.whats the problem with my code?i run this in google chrome,but it runs without any problem.it doesnt display any error messages?please help me out.

my javascript is

<script>
    $(document).ready(function() 
    {
var wrong="nnnn.htm";  
    var name = prompt("Please type in the password",''); 
    $.ajax({
    type: 'POST',
    dataType: 'json',
    url: 'password.php',
    data: {
    name: name
        },
    success: function(data) 
    {
        if (data.success == "good") 
             {


                 window.location.href =data.address;

             }    
        else 
             {
                 alert(data);
                location.href=wrong
             }
    },
    error: function(data) 
    {

        location.href=wrong;
    },
        });
        });
    </script>

my php page is

<?php
$password="123";
$prompt_password=$_POST['name'];
$success="good";
if($prompt_password==$password)
{
$output =  array('success'=>'good',
          'address'=>'itms-services://?action=download-   manifest&url=http://feathersoft.net/projects/tests/Corelogic/Alert/AlertApp.plist');
echo json_encode($output,JSON_FORCE_OBJECT);
}
else
{
echo "error";
}

?>

回答1:


Firefox is showing that error because it does not now how to handle itms-services:// protocol.

Goto about:config in Firefox and search for network.protocol-handler if you can see any setting for network.protocol-handler.external.itms-services then only Firefox can handle your request.

Change self.location.href = data.address to self.location = data.address as href is used for HTTP.




回答2:


The error message ns_error_unknown_protocol is basically saying is the browser does not know how to handle your custom protocol itms-services://.

I thinking it has to do with the href setting.

Try changing it to

self.location = data.address;


来源:https://stackoverflow.com/questions/15409270/getting-an-error-ns-error-unknown-protocol

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!