Jump to content

Setting URL var to a constant url --- changing textbox parameter


Recommended Posts

Is there a way to set this javascript code to a constant url rather than allowing a user to type in the url address?

 

 


<html>
<head> 
<title></title>
<script type="text/javascript"> 
	var Drag = {};
	var gui;
	var cut;
	var outer;
	var IE;
	var url;
	var site;
	var exp;
	var fade;
	var m={x:0,y:0};
	var pan=false;
	var mouseDown=false;
	var jailbreak;
	function init() {
		IE = document.all?true:false;
		if (!IE) document.captureEvents(Event.MOUSEMOVE);
		document.onmousemove = getMouseXY;
		gui = document.getElementById('gui');
		cut = document.getElementById('cut');
		outer = document.getElementById('outer');
		url = document.getElementById('url');
		site = document.getElementById('site');
		exp = document.getElementById('export');
		fade = document.getElementById('fade');
		url.focus();
		gui.onmousedown = function () {
			url.focus();
			mouseDown = true;
			exp.style.display = '';
			exp.onmouseup = gui.onmouseup = function () {
				mouseDown = false;
				url.value = url.value.split(' ').join('');
				gui.onmousemove = null;
			}
			var tmpX = m.x;
			var tmpY = m.y;
			var tmpSiteY = parseInt(site.style.top);
			var tmpSiteX = parseInt(site.style.left);
			if(!pan) {
				outer.style.top = tmpY+"px";
				outer.style.left = tmpX+"px";
				cut.style.top = -tmpY+parseInt(site.style.top)+"px";
				cut.style.left = -tmpX+parseInt(site.style.left)+"px";
				cut.style.width = site.offsetWidth+"px";
				cut.style.height = site.offsetHeight+"px";
			}
			gui.onmousemove = function () {
				if(pan && mouseDown) { 
					site.style.top = tmpSiteY+(m.y-tmpY)+"px";
					site.style.left = tmpSiteX+(m.x-tmpX)+"px"; 
					cut.style.top = tmpSiteY+m.y-tmpY-parseInt(outer.style.top)+"px";
					cut.style.left = tmpSiteX+m.x-tmpX-parseInt(outer.style.left)+"px";
				} else {
					if(m.y-tmpY<0) { 
						outer.style.top = m.y+"px";
						outer.style.height = (tmpY-m.y)+"px";
						outer.style.minHeight = (tmpY-m.y)+"px";
						cut.style.top = -m.y+parseInt(site.style.top)+"px";
					} else {
						outer.style.height = (m.y-tmpY)+"px";
						outer.style.minHeight = (m.y-tmpY)+"px";
					}

					if(m.x-tmpX<0) {
						outer.style.left = m.x+"px";
						outer.style.width = (tmpX-m.x)+"px";
						cut.style.left = -m.x+parseInt(site.style.left)+"px";
					} else {
						outer.style.width = (m.x-tmpX)+"px";
					}
					exp.style.top = parseInt(outer.style.top)+parseInt(outer.style.height)+"px";
					exp.style.left = parseInt(outer.style.left)+parseInt(outer.style.width)-50+"px"; 

				return false;
				}
				var wSize = window.size();
				cut.style.minHeight = site.style.minHeight = site.style.height = cut.style.height = wSize.height+Math.abs(parseInt(site.style.top))+"px";
				site.style.width = cut.style.width = wSize.width+Math.abs(parseInt(site.style.left))+"px";
				return false;	
			}
			return false;
		}
		return false;
	}

	getMouseXY = function (e) {
		if (IE) {
			m.x = event.clientX + document.body.scrollLeft;
			m.y = event.clientY + document.body.scrollTop;
		} else {
    			m.x = e.pageX;
    			m.y = e.pageY;
  			}
  			if (m.x<0) m.x=0;
  			if (m.y<0) m.y=0;
  			return true;
	}

	window.size = function() {
		var w = 0;
		var h = 0;
		if(!window.innerWidth) {
			if(!(document.documentElement.clientWidth == 0)) {
				w = document.documentElement.clientWidth;
				h = document.documentElement.clientHeight;
			} else {
				w = document.body.clientWidth;
				h = document.body.clientHeight;
			}
		} else {
			w = window.innerWidth;
			h = window.innerHeight;
		}
	return {width:w,height:h};
	}

	Drag.start = function () {
	var elem = document.getElementById('urlbox');
		var dX = m.x-parseInt(elem.style.left);
		var dY = m.y-parseInt(elem.style.top);
		document.body.onmouseup = function () {
			Drag.stop(this);
		}
		document.body.onmousemove = function () {
			elem.style.left = m.x-dX+"px";
			elem.style.top = m.y-dY+"px";
		}
	}
	Drag.stop = function (elem) {
		elem.onmousemove = null;
	}

	changeurl = function (e) {
		var keyCode;
		if(window.event) {
  				keyCode = e.keyCode;
  			} else if(e.which) {
			keyCode = e.which;
		}
		if(32==keyCode) {
			url.value = url.value.split(' ').join('');
		} else if(13==keyCode) {
			cut.src = url.value;
			site.src = url.value;
			return false;
		}
	return true;
	}

	dopan = function (e) {
		var keyCode;
		if(window.event) {
  				keyCode = e.keyCode;
  			} else if(e.which) {
			keyCode = e.which;
		}
		if(32==keyCode) {
			pan=true;
			document.body.style.cursor='move';
		}
	return true;
	}

	stoppan = function (e) {
		pan=false;
		document.body.style.cursor='default';
	return true;
	}

	defaultdisabled = function (e) {
	if (!e)
		event.returnValue = false;
	else
		e.preventDefault();
		return false;
	}

	genIframe = function () {
		var normalCode = "<div style=\"overflow: hidden; width: "+outer.style.width+"; height: "+outer.style.height+"; position: relative;\" id=\"i_div\">\n<iframe name=\"i_frame\" src=\""+url.value+"\" style=\"border: 0pt none ; left: "+cut.style.left+"; top: "+cut.style.top+"; position: absolute; width: "+cut.style.width+"; height: "+cut.style.height+";\" scrolling=\"no\"><\/iframe><\>";
			if(navigator.userAgent.indexOf("Firefox") != -1) {
   					var win = window.open('');
				var doc = win.document;
				doc.open("text/html", "replace");
					var normalDisplay = "<h1>Copy & Paste</h1><textarea style=\"width:400px;height:200px;\">"+normalCode+"</textarea>";
				doc.write(normalDisplay);
				doc.close();
   				} else {
				var example = window.open();
				if(example) {
					var doc = example.contentDocument?example.contentDocument:example.document;					
					var normalDisplay = doc.createElement('textarea');
					normalDisplay.innerText = normalCode;
					normalDisplay.style.width = "400px";
					normalDisplay.style.height = "200px";
					var h2 = doc.createElement('h1');
					h2.innerText = 'Copy & Paste;';
					doc.body.appendChild(h2);
					doc.body.appendChild(normalDisplay);
					example.focus();
				}
			}
		return true;
	}
</script> 
<style type="text/css"> 
* {margin:0px; padding:0px;font-size:12px;font-family: sans-serif;}
body, div { height:100%;}
#outer {
position:absolute;
left:0px;
top: 0px;
width:250px;
height:250px;
overflow:hidden;
}

a {
color: #3d6d91;
text-decoration: none;
}

.black_overlay{
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color: black;
-moz-opacity: 0.8;
opacity:.80;
filter: alpha(opacity=80);
}
.ui_overlay{
position: absolute;
top: 0%;
left: 0%;
width: 100%;
height: 100%;
background-color: white;
z-index:1001;
-moz-opacity: 0.0;
opacity:.00;
filter: alpha(opacity=00);
}
</style> 
</head> 
<body style="width:100%;height:100%;overflow:hidden;" onload="init();" ondragstart="return false" onkeydown="return dopan(event);" onkeyup="return stoppan(event);"> 
<iframe id="site" src="http://www.blackhatworld.com" style="width:100%;min-height:100%;height:100%;position:absolute;top:0px;left:0px;z-index:0;border:none;background:#fff;" scrolling="no" onmousedown="return defaultdisabled(event);"></iframe> 
<div id="fade" class="black_overlay" style="z-index:1;" onmousedown="return defaultdisabled(event);"><> 
<div id="outer" style="width:100%;height:100%;position:absolute;top:0px;left:0px;z-index:2;border:none;" onmousedown="return defaultdisabled(event);"> 
<iframe id="cut" src="http://www.blackhatworld.com" style="width:100%;min-height:100%;height:100%;position:absolute;top:0px;left:0px;border:none;background:#fff;" scrolling="no" onmousedown="return defaultdisabled(event);"></iframe><> 
<div id="gui" class="ui_overlay" style="z-index:3;" onmousedown="return defaultdisabled(event);"><> 
<div id="urlbox" style="z-index:4;min-height:20px;height:20px;line-height:20px;border:0px;position:absolute;top:0px;left:0px;"><img style="display:block;float:left" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUCAYAAACNiR0NAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABFdJREFUeNp0VM1PXFUU/9377nvz3nwwMCjy1Vpg7BBFxEApqF3YyKZNF9Wd0USjLkyMbvsPuHLlxoULN+1Comki6qLVavxIqUgaihFpYWillCIw38PM+7zXMzMFWmPv5OS+N/e+3zm/8zvnIPCyCLw8lHJQnPoSK4cOY214HG26DlrjZCO1B8YY3nzjNVSrJShZpm+KCNxtBH6BLAevsEUYCgL3rdofkqxZAaejTT0Ltr05BJ4OXnwe73/8EVLJw3RLgwwqeNh6AJBxBuX5EXlkbPLD5BNHt2amb4UrlTMtJ05diiUHoIICwK2a690Q9nf6tg7IQCBER8GGOTYCkex5hbUkTup0rrj2yAbXP2sdSL0Ky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C/dnO+JUfPP8HEWXIyTbl2HxDvIetfAQYAoOUIbSv9JcAAAAAASUVORK5CYII=" onmousedown="Drag.start();return defaultdisabled(event);"/><input type="text" id="url" style="float:left;min-height:20px;height:20px;width:175px;" value="http://url.here" onkeydown="return changeurl(event);"></input><> 
<div id="export" style="z-index:5;position:absolute;top:0px;left:0px;display:none;"><input type="button" value="Export" style="min-height:20px;height:20px;width:50px;" onclick="genIframe();"></input><> 
</body> </html>

It must be possible?

I mean, in the JavaScript, it has a var named url that gets set by whatever the user puts in the textbox, and when the user presses enter or return, the page of the url is displayed. I want to know if there is a way to set this JavaScript up to instead of waiting for the user to type in a url in the textbox, if we could eliminate the textbox and set the value of the variable to a specific url instead? Did that make any more sense?

I want to know if there is a way to set this JavaScript up to instead of waiting for the user to type in a url in the textbox, if we could eliminate the textbox and set the value of the variable to a specific url instead?

 

Well, ya. Just hardcode it into the function....

In other words, set the URL variable manually in the JS function.

Can you help me get this started? I am new to JavaScript and am having a hard time setting the code up correctly. I tried setting the var url to the value of the url I wanted to use, and also setting the value of the textbox to the url I wanted to use, but I do not know how to set toe code to run the script as it loads instead of when the user presses enter on the textbox. Should i set it to the textbox and make it invisible or is there a better way? Can you please help?

I have tried setting the value of the textbox to the url I wanted to use, and then instead of the onKeyRelease event, I tried using onLoad and onFocus, but neither of these are working. Can you please help me with this?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.