Showing posts with label redirect. Show all posts
Showing posts with label redirect. Show all posts

Thursday, December 28, 2017

URL Redirect: Redirecting From of an iFrame


IFrame


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>IFrame Title</title>
    <script type="text/javascript" src="//code.jquery.com/jquery-1.9.1.js"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            $("button").click(function() {
                window.top.location.href = 'https://pritomkumar.blogspot.com';
            });
        });
    </script>
</head>
<body>
<button type="button">Reload IFrame Parent</button>
</body>
</html>

To modify your iframe embed code, you will add the following attribute inside the opening iframe tag:
sandbox="allow-top-navigation allow-scripts allow-forms"

Container of IFrame


<style type="text/css">
    iframe {
        width: 40%;
        height: 95%;
        margin-left: calc(30%);
        border: 1px solid lightgray;
    }
</style>
<div>
    <iframe src="iframe-html.php" sandbox="allow-top-navigation allow-scripts allow-forms"></iframe>
</div>

Thursday, June 22, 2017

Laravel 5:Redirect back to the same page where the request comes from with input and messages

In your controller:

use Illuminate\Support\Facades\Redirect;

$error[] = "SOME ERRORS";
return Redirect::back()
    ->withErrors(compact('error'))
    ->with("reason1", "SOME REASON 1")
    ->with("reason2", "SOME REASON 2")
    ->withInput();


And in your view file:

<div>Reason1: {{ session('reason1') }}</div>

<div>Reason1: {{ session('reason2') }}</div>

Option "withInput" will fill back up input fields with previous data:

{!! Form::label('name', 'Name:') !!}

Saturday, January 14, 2017

Implement Redirect Interceptor For All Http Call - Angular JS

Download resources from here


<script type="text/javascript" src="angular.js"></script>
<script type="text/javascript" src="angular-resource.js"></script>

<div data-ng-app="myApp" data-ng-controller="MyCtrl">[[dataFromAngularJS]]</div>

<script type="text/javascript">
    var app = angular.module('myApp', ['ngResource'], function ($interpolateProvider) {
        $interpolateProvider.startSymbol('[[');
        $interpolateProvider.endSymbol(']]');
    });
    app.config(['$httpProvider', '$controllerProvider', function ($httpProvider, $controllerProvider, $window) {
        $httpProvider.interceptors.push('redirectInterceptor');
    }])
    .run(function ($rootScope, $window) {
        console.log("MY_APP START RUNNING");
        $rootScope.baseUrl = "/";
    })
    .factory('redirectInterceptor', function ($q, $location, $window, $rootScope) {
        return {
            response: function (response) {
                console.log("GOT DATA VIA AJAX CALL");
                console.log(response);
                return response;
            },
            responseError: function(response) {
                console.log("GOT ERROR VIA AJAX CALL");
                console.log(response);
                response.data = "ERROR";
                return $q.reject(response);
            }
        }
    });

    app.controller('MyCtrl', ['$scope', '$http', function ($scope, $http) {
        $scope.dataFromAngularJS = "Data From Angular JS";

        $http.get('data.html').
        success(function(response, status, headers, config) {
            $scope.dataFromAngularJS = "Success=" + response;
        }).
        error(function(response, status, headers, config) {
            $scope.dataFromAngularJS = "Error=" + response;
        });
    }]);
</script>

Monday, September 9, 2013

Redirect your site to https and www using htaccess

<ifmodule mod_rewrite.c>
   RewriteEngine on

   RewriteCond %{HTTPS} off
   RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
   RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

   RewriteCond %{HTTPS} off
   RewriteCond %{HTTP_HOST} !^www\.(.+)$ [NC]
   RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]

   RewriteCond %{HTTPS} on
   RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
   RewriteRule ^(.*)$ https://%1/$1 [R=301,L]

   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]
</ifmodule>