View Full Version : URL Bar Javascript
boxxertrumps
06-14-2006, 02:23 PM
Hello, i need a script that has an input feild and the input is URL's. when a go button is clicked the url open in an inline frame. if you could write in a Back/Forward Script that'd be great.
PS. if it isnt conceivable please tell me.
neomaximus2k
06-14-2006, 03:19 PM
Hello, i need a script that has an input feild and the input is URL's. when a go button is clicked the url open in an inline frame. if you could write in a Back/Forward Script that'd be great.
PS. if it isnt conceivable please tell me.
Its doable... at a rough guess (not tested this script)
<input type="text" name="url" id="url">
<input type="button" onclick="showurl">
your iframe would be something like this
<iframe name="theiframe" id="theiframe">
and the Javascript code would look like
function showurl(){
if (document.getElementById('url').value != ""){
theiframe.location = document.getElementById('url').value;
} else {
alert('No URL Entered');
}
}
for the forward and back i think this will work
<a href="Javascript:;" onclick"theiframe.history(-1);">
not tested any of that tho going off memory
jscheuer1
06-14-2006, 04:54 PM
Close but, with several errors, try:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>Mini Browser</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
function showurl(){
if (document.getElementById('url').value != "")
theiframe.location.href = document.getElementById('url').value;
else
alert('No URL Entered');
}
</script>
</head>
<body>
<input type="text" id="url"><br>
<input type="button" onclick="showurl();"><br>
<iframe name="theiframe"></iframe><br>
<a href="javascript:void(0);" onclick="history.go(-1);return false;">Back</a> <a href="javascript:void(0);" onclick="history.go(1);return false;">Forward</a>
</body>
</html>
Note: The back link will take you to the previous page in the history stack (if any) if there is nothing to go back to in the iframe. By launching the above page as a new window, that should eliminate that possibility.
shachi
06-14-2006, 05:25 PM
Hey try this out: http://captninsano.tripod.com/browser.html
Recently Updated!!:p
(Works in FF 1.5 IE 5-6 but unfortunately not in Opera :( Has an extra feature{shows history when Ctrl is pressed})
If you are searching for something like that then I can provide you the code(freely distributable with appropriate credits). If you are not searching for something like that then it's not a problem at all.:)
jscheuer1
06-14-2006, 06:13 PM
Hey try this out: http://captninsano.tripod.com/browser.html
Recently Updated!!:p
(Works in FF 1.5 IE 5-6 but unfortunately not in Opera :( Has an extra feature{shows history when Ctrl is pressed})
If you are searching for something like that then I can provide you the code(freely distributable with appropriate credits). If you are not searching for something like that then it's not a problem at all.:)
The stop and refresh buttons can get you into trouble in FF and also cancel the history list feature in that browser. The page jumps from left to right when using the history and individual entries in the history reveal feature do not each have their own line.
shachi
06-14-2006, 07:16 PM
The stop and refresh buttons can get you into trouble in FF and also cancel the history list feature in that browser. The page jumps from left to right when using the history and individual entries in the history reveal feature do not each have their own line.
The jumping page was made on purpose(so as to make it look like FF) and by the way I didn't get how can i get into trouble if I use the stop and refresh buttons??:confused: And can you also tell me why "history reveal feature do not each have their own line" I would try to show it in a single line if it is not correct.:)
jscheuer1
06-14-2006, 08:29 PM
The jumping page was made on purpose(so as to make it look like FF) and by the way I didn't get how can i get into trouble if I use the stop and refresh buttons??:confused: And can you also tell me why "history reveal feature do not each have their own line" I would try to show it in a single line if it is not correct.:)
The history lines could probably be fixed easily enough, if you are using an element's innerHTML to write them out, simply by inserting <br> tags after each entry after you append it. A nice touch would be to construct the list in such a way as to make each item a link to itself, with the target being the iframe.
I would think that Stop and Refresh should either be skipped or work as in a browser. If I hit Stop in the browser and then refresh, the page I was loading reloads and the history remains intact, neither of those happened.
These things could probably be achieved with (a) session cookie(s).
With the jumping history, to make it like FF (IE does this too) you could use an iframe or scrolling division (probably best) or frame to contain the history. This would make it more like those browsers are when their history buttons are clicked.
I realize that when designing something like this that there often is a tendency not to try and 'push the envelope' on the features when testing but, these thing will be done, as a matter of course, by individuals using the design.
Overall, I should mention that the design looked nice but, with its reliance on javascript and the fact that at best, it merely duplicates what the user has before them to begin with, I wonder about its usefulness. These reservations apply to this thread in general but, it is an interesting exercise.
I wonder why the OP wanted something like this to begin with.
boxxertrumps
06-14-2006, 08:35 PM
The Internet Does Care... and here's the finished product.
MY PAGE! (http://www.freewebs.com/boxxertrumps)
neomaximus2k
06-14-2006, 09:31 PM
The Internet Does Care... and here's the finished product.
MY PAGE! (http://www.freewebs.com/boxxertrumps)
Nice glad the JS code worked,... well once it got the bugs taken out lol like i said was coded from memory and didnt have chance to check it over
shachi
06-15-2006, 06:56 AM
The history lines could probably be fixed easily enough, if you are using an element's innerHTML to write them out, simply by inserting <br> tags after each entry after you append it. A nice touch would be to construct the list in such a way as to make each item a link to itself, with the target being the iframe.
I would think that Stop and Refresh should either be skipped or work as in a browser. If I hit Stop in the browser and then refresh, the page I was loading reloads and the history remains intact, neither of those happened.
These things could probably be achieved with (a) session cookie(s).
With the jumping history, to make it like FF (IE does this too) you could use an iframe or scrolling division (probably best) or frame to contain the history. This would make it more like those browsers are when their history buttons are clicked.
I realize that when designing something like this that there often is a tendency not to try and 'push the envelope' on the features when testing but, these thing will be done, as a matter of course, by individuals using the design.
Overall, I should mention that the design looked nice but, with its reliance on javascript and the fact that at best, it merely duplicates what the user has before them to begin with, I wonder about its usefulness. These reservations apply to this thread in general but, it is an interesting exercise.
I wonder why the OP wanted something like this to begin with.
It was just made as an experiment(you know it as you helped me making it) not in a way to give some facilities to people(because I knew that people would already have a browser to see one like that). And I still don't know how to make cookies(as I am just a beginner). :( But anyways if you wish then you can make some changes in it too.:)
If you wish
boxxertrumps
06-16-2006, 12:41 AM
what kind of code would be needed to make the ifame and the Textbox continually equal?
is the an Onchange event so that when the iframe loads a new page a Var is equal to the url?
Unfortunately not... this would be very difficult, since you're not allowed to read the URL the iframe is pointing to if it's on a different domain.
boxxertrumps
06-16-2006, 01:19 PM
not allowed or not possible?
b/c if it isnt allowed ill do it anyway.
Not allowed by the browser, and therefore not possible :)
jscheuer1
06-16-2006, 05:01 PM
I'm not sure if there is not a slight bit of confusion here over 'what you can read from the iframe' and 'what could be known by the script'. It may be true that you cannot poll the iframe for its url but, you can certainly keep track of any user entered strings used for navigation within it.
The problem is that the OP wishes to update the "address bar" if the user, for example, clicks on a link within the iframe.
jscheuer1
06-16-2006, 05:51 PM
Get a browser for that. Or, for all the functionality of a browser in a simpler looking interface, open a new window with just the address and tool bars. In simple terms:
window.open('about:blank','_blank','width=400, height=400, location=1, toolbar=1')
Or as part of my previous code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
<html>
<head>
<title>External Mini Browser</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script type="text/javascript">
var win
function showurl(){
if (document.getElementById('url').value != ""){
win = window.open(document.getElementById('url').value,'win1','width=400, height=400, location=1, toolbar=1');
win.focus()
}
else
alert('No URL Entered');
}
</script>
</head>
<body>
<input type="text" id="url"><br>
<input type="button" onclick="showurl();">
</body>
</html>
I still scratch my head as to why we need to imitate a browser when we are looking at it through one.
Agreed. Why not just write an actual browser? :)
shachi
06-16-2006, 08:15 PM
Agreed. Why not just write an actual browser? :)
Simple coz we can't.:(
The Firefox source code (http://www.mozilla.org/projects/firefox/) is available for modification and redistribution under the terms of the Mozilla Public License. You should have a look, it'd be a horizon-broadening experience for you.
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.