Hi,
I am Using iframe for the URL masking. But it's not working for me.

Am using Xampp:

1. http://localhost/professor.html
(a).professor.html page in xampp htdocs folder (htdocs/professor.html)
(b).professor.html page -> Is a authenticated Page, getting userid and the password in the professor.html page and once the login gets true, moves to professor details page.
(c) Professor details page under => htdocs/auth/employee.php
(d) whenever i submit the professor.html page : in the address bar am getting
http://localhost/auth/employee.php

(e) iframeset tag added in =>htdocs/auth/index.html (It's not working)

<html>
<body>
  <iframe src="professor.html" width="100%" height="100%" frameborder="0" scrolling="no" /></iframe>
</body>
</html>

(f) I need the URL in the address bar as like :
http://localhost/professor.html

Please any one help me out in solving this.

you mean like this?

target="_top"

<iframe src="professor.html" width="100%" height="100%" frameborder="0" scrolling="no" target="_top"/></iframe>

I dont get the purpose of url masking, why hide it? it's easy to find it out if you really want to

I don't quite get what or why you are setting it up that way.

The address bar is the url of the top most page not the iframe, setting target='_top' tells the browser that any links within the iframe should replace the topmost parent (the browser window) address rather than opening it up inside the iframe.

Surely if you want the address bar to be http://localhost/professors.html, you just send the user to http://localhost/professors.html

if you are submitting a form inside an iframe and you don't want the url to change it is probably _self you want, the problem is this is the default setting so it should of worked that way without any target set.

How are you doing the redirect to http://localhost/auth/employee.php?

am not able to get from your answer :-(

example:

webpage
<body>
<a href='page2.htm'>webpage link</a>
<iframe>
<a href='page3.htm'>link inside iframe</a>
</iframe>
</body>

The webpage link will redirect the address bar to page2.htm.
The iframe link will redirect the iframe to page3.htm, address bar stays the same

example 2:

webpage
<body>
<a href='page2.htm' target='myiframe'>webpage link</a>
<iframe name='myiframe'>
<a href='page3.htm' target='_top'>link inside iframe</a>
</iframe>
</body>

The webpage link will open page2.htm inside the iframe named 'myiframe'
The iframe link will redirect the browser to 'page3.htm'

if you have this sort of setup:
example 3:

webpage
<body>

<iframe name='myiframe'>
<form method='post' action='process.php'>
</form>
</iframe>
</body>

Submitting the form in the iframe will redirect the iframe to 'process.php'
The address will stay the same unless you are using some sort of redirect in the action page

This makes me wonder how you are sending the user to http://localhost/auth/employee.php

Can you not show any of the code on http://localhost/professor.html?

Member Avatar for diafol

Iframes/frames can be set via js on links. But you could also use an ajax script for this. It breaks the back button, but you want a total mask right?

Alternative:
main file:

<hmtl>
<head>
<script src=" https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $('.jlink').click(function(e){
		e.preventDefault();
		strlen = (window.location.href).length + 1;
		var dest = this.href.substring(strlen);
		$.post("hub.php", { id: dest },
   			function(data) {
     			$('#results').html(data);
   		});
	});
});
</script>
</head>
<body>

<a href="?0" class="jlink">page1</a>
<a href="?1" class="jlink">prof</a>
<a href="?2" class="jlink">emblem</a>

<div id="results">
	<?php include("default.php");?>
</div>
</body>
</html>

hub.php:

<?php
$array = array('page1.php','prof.html','emblem.htm');
if(isset($_POST['id']) && isset($array[$_POST['id']])){
	include($array[$_POST['id']]);
}else{
	include('default.php');	
}
?>

Note that the link id's can be generated by php as can the array in hub.php (e.g. from DB).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.