How to redirect a page to new window using codeigniter redirect function - codeigniter-2

i need make redirecting my content in new tab after some code checking.
if ($this->form_validation->run('name') == FALSE) {
//...
Show form errors in some windows
//..
} else {
redirect("home/bill_print");
Please help.

You can't use a server-side language (PHP) to control client-side behavior. You can Open a URL in a new tab using JavaScript window.open function.

Related

Catch windows.external.notify posted message from UIWebview in UIViewController Xamarin-iOS

I have a scenario where I'm trying to login from UIWebview and if authenticated successfully then I'm getting a string token using script snippet window.external.notify I'm able to get token in windows phone using myWebView.ScriptNotify+=WinNotify; and in android using myWebView.AddJavascriptInterface(new ExternalInterface(),"");
but the problem is that I'm not able to detect any code snippet in iOS webview to read this notify script.
I've tried This where I've used IWKScriptMessageHandler but didn't work.
Can you guys please help me to get it done in iOS?
I've done something like this a some while ago for Azure Access Control Services. The code can be found here: https://github.com/Cheesebaron/Cheesebaron.MvxPlugins/blob/0e8b7765fe375d1d4998552074d664e6cf5397a3/AzureAccessControl/AzureAccessControl.Touch/Views/AccessControlWebAuthController.cs
Basically what this does is injecting a Notify script into the page, when that script is invoked, it navigates to a specific URL that I know and from that I can grab the payload.
private const string ScriptNotify = #"
<script type=""text/javascript"">
window.external = {
'Notify': function(s) {
document.location = 'acs://settoken?token=' + s;
},
'notify': function(s) {
document.location = 'acs://settoken?token=' + s;
}
};
</script>";
So the code above navigates to acs://settoken?token= when the notify script is invoked. You can detect this in UIWebView.ShouldStartLoad by checking the url scheme. If it matches the one in the notify script you are done.
To inject the script, I implement NSUrlConnectionDelegate and in the FinishedLoading override I inject it as part of the data and make the UIWebView load that content instead.

Cross domain issue on IE

I am working with a project which needs cross domain ajax. I chose cors for this purpose. It works perfectly in chrome and firefox. But in IE, the browser is not creating any ajax call.there is no console errors at all. Can anyone tell me a solution for this?
For IE, you cannot use normal ajax for cross domain access. You need to use XDomainRequest() for this.
Example:
xdr = new XDomainRequest();
if (xdr) {
xdr.onload = function () {
alert(xdr.responseText);
};
xdr.open("get", url);
xdr.send();
}

How can I get http headers in WebBrowser?

I wrote a WP7 web browser app called "Cute Browser".
There is a problem that when navigating to an unkown content-type page such as 'application/stream', the WebBrowser is always navigating.
After my many experiments, I found out a method to detect the always navigating status using invoke the script:
var readyStateChange = function(){
if(document.readyState == 'interactive') {
document.detachEvent('onreadystatechange', readyStateChange);
window.external.Notify('MaybeWml');
}
}
if(document.readyState != 'complete'){
document.attachEvent('onreadystatechange', readyStateChange);
}
I want to know is any possible to get the Http Headers using WebBrowser without start another HttpRequest?

FBJS AJAX.post is not working after permissions dialog

I have problems with facebook application based on flash which communicate with PHP using FBJS-bridge. When someone use the application for the first time, he/she is asked for various permissions. After that, flash contact PHP with ajax but request is never sent. When you refresh page, everything is working without any problems.
If you remove the application on privacy settings, refresh the page and try again - same bug happens. If you allow application, refresh page, in other tab remove application and start application in previous tab - user is asked for permissions but everything is working after allowing application.
This is FBJS code
function openPermissions(){
Facebook.showPermissionDialog(/*permissions string*/, permissionOnDone);
}
function permissionOnDone(perms){
if (!perms) {
document.getElementById("indexswf").callSWF('noallow');
} else {
document.getElementById("indexswf").callSWF('allow');
}
}
function ajaxCall(url,parameters){
var params = {};
for(var i=0;i<parameters.length;i+=2){
params[parameters[i]]=parameters[i+1];
}
ajax = new Ajax();
ajax.requireLogin = true;
ajax.responseType = Ajax.RAW;
ajax.ondone = function(data){
document.getElementById("indexswf").callSWF('parseAjax', data);
}
ajax.post('http://the.url.to/the_real_server/not_to_the_fb_url/'+url,params);
}
openPermissions is called to display permission dialog, and on allow flash function allow() is called. In flash, allow() calls JS function ajaxCall(), which should make ajax request. But, ajax.post never sends request. I know that for sure, because flash function parseAjax was never called and also debugging tools in browsers are not showing any ajax requests. URL and parameters are same as when it is working. No flash or JS errors are detected...
Anyone have idea what is wrong here? Maybe facebook bug again since this was all working few days ago...
ajax.requireLogin = true should be set to false for some reason

WP7 WebBrowser control headers

HI, is possible to add request headers in WP7 WebBrowser control?
There is no way to do this. If you need to change headers you'll need to use HttpWebRequest.
You could intercept the requests from the WebBrowser control and make them yourself via HWR but this could get complicated very quickly.
No - I don't think there's any API hook available for this.
It's a similar problem to the "change the user agent" request discussed in Bring back mobile version of website in WebBrowser control for wp7?
Sorry to necro but the answers here are wrong. Headers can be added to a WebBrowser through the Navigate method.
WebBrowser.Navigate(YourURI, null, YourCustomHeaderString)
See this page: http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff626636(v=vs.105).aspx
.
These headers will only apply to the first page navigated to through your code. If you want the headers to stay the same even when users click a link inside the web browser control, add this for the WebBrowser's navigating event:
private void browser_Navigating(object sender, NavigatingEventArgs e)
{
string url = e.Uri.ToString();
if(!url.Contains("YESHEADERS"))
{
e.Cancel = true;
string newUrl;
if(url.Contains("?"))
{
newUrl = url + "&YESHEADERS";
}
else
{
newUrl = url + "?YESHEADERS";
}
browser.Navigate(newUrl, null, "fore:" + Variables.GetForeground() + "")
}
}
Here's what that does:
We create an indicator, YESHEADERS, that tells us whether or not we have added custom headers.
When the WebBrowser tries to Navigate, we check whether or not the URL it is navigating to, e.Uri, contains YESHEADERS.
If it does, we've already added our headers. Take no action
If it does not, cancel the current navigation. Create a new URL equal to the old URL plus our indicator. We add YESHEADERS on to the new URL in it's query string. If you are not familiar with query strings that is fine, just know that they are extra strings on the URL that have no effect in our case. About Query Strings
Then, we navigate to the new URL, and add our custom headers.
In short, if we have our indicator YESHEADERS the web browser knows that we've added our custom headers, if we don't have YESHEADERS, than the web browser needs to add the headers.

Resources