Jump to content

[SOLVED] Javascript and framesets


maxz_pc

Recommended Posts

Hi,

 

I have a main page that has some content at the top and a frame set. There are two frames in the frameset: one of the left(menu:150px) and one on the right(content:auto width)

 

Now I want to create a dynamic autosuggest search tool with AJAX. The problem is that when the autosuggest suggest things, it makes a scrollbar in the left frame because the auto suggest is larger than the frame's width.

 

The thing is that I don't want to have a scroll. I want my auto suggest to be on top of everything. This is where i need help.

 

I would need to create a div element in the root page. This element would need to be positioned at the same place as it would in the frame. So I need horizontal and vertical offsets to add them up.

 

I'm using prototype but the solution doesn't need to have prototype involded.

The harder thing is that it needs to work on IE6, IE7 and FF

 

Thanks

Max

 

Link to comment
Share on other sites

My problem is not really vertical scroll but more horizontal scroll, that is the reason why i want to create a div element with absolute coordinates on the root window. So that it would be on top of everything with a z-index higher than anything else on the page.

Link to comment
Share on other sites

Thank you for the example, but it doesn't show the right things.

 

anyways, i found my solution with window.parent

 

top frame

<div id="autoSuggestions" style="position: absolute; z-index: 100; width:200px;">
<div id="autoSuggest" style="postion: relative; width: 100%;" ></div>
</div>

 

left frame

<input type="text" id="test" name="test" value="test" onkeyup="myFunction(this);">

<script>
	function myFunction(e){
		var name = e.value;
		if(name.length > 2){
			var viewPortOffset = [e.offsetLeft,e.offsetTop];
			var xOffset = viewPortOffset[0] + (e.clientWidth * 0.5) ;
			var yOffset = viewPortOffset[1] + (e.clientHeight);

			xOffset += window.parent.$('frmMenu').viewportOffset()[0];
			yOffset += window.parent.$('frmMenu').viewportOffset()[1];

			window.parent.$('autoSuggestions').style.top = yOffset +'px';
			window.parent.$('autoSuggestions').style.left = xOffset +'px';

			var myhash = new Hash();
			myhash.name = name;

			new Ajax.Request('/search_person_results.php',
			  {
			    method:'post',
			    parameters: myhash,
			    encoding: 'iso-8859-1',
			    onSuccess: function(transport){
			      window.parent.$('autoSuggest').update(transport.responseText);
			    },
			    onFailure: function(){ alert('Something went wrong...') }
			  });
		}
	}
</script>

Link to comment
Share on other sites

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.