Forum Moderators: coopster

Message Too Old, No Replies

Redirecting To A Full Page Window

         

capulet_x

7:09 pm on Apr 8, 2007 (gmt 0)

10+ Year Member



Hello,

I've been tying to escape frames and redirect to a new window. I've been employing a javascript like this to open the window up:

<SCRIPT LANGUAGE="JavaScript">
<!--

if (window!= top) top.location.href = location.href;

// -->
</SCRIPT>

The problem is that by doing this a keep conflicting with header ( Location:http://www.example.com)

My question is I know I need AJAX to accomplish what I want but how do I apply this or can someone refer me to a tutorial?

ahmedtheking

7:24 pm on Apr 8, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Easy, have a read of: [ajaxlessons.com...]

capulet_x

7:55 pm on Apr 8, 2007 (gmt 0)

10+ Year Member



thank you for your quick response, Ahmedtheking...

I am using a shared server. It looks like the link you provided requires some sort of installation. Is there no way to do this with straight scripting?

ahmedtheking

8:05 pm on Apr 8, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nah it's all JS so it's client side! Basically:

1. Go and get yourself prototype.js from: [prototypejs.org...] (Save it to your web dir under a folder, say, js)

2. Add it into the head of your doc(s): <script type="text/javascript" src="/js/prototype.js"></script>

3. Start playing! You see, AJAX is a HTTPXMLRequest. What it means is that your browser is receiving and sending POST/GET data behind the back. A simple request is as follows:

new Ajax.Request('/some_url',
{
method:'get',
onSuccess: function(transport){
var response = transport.responseText ¦¦ "no response text";
alert("Success! \n\n" + response);
},
onFailure: function(){ alert('Something went wrong...') }
});

It's really simple. If you're wanting to look at adding data into elements, such as DIVs, prototype has added DOM capabilities so that you can select an element (by it's ID) by doing $('ELEMENTSID') and then adding whatever you need to it!

Now I know this is a bit too much to take it, so have a read of: [prototypejs.org...] and take it one step at a time. Have fun!

capulet_x

9:50 pm on Apr 8, 2007 (gmt 0)

10+ Year Member



Strangely enough my solution ended up being simply to add:

target="_parent"

As In:

<form action="myURL" method="post" target="_parent">

Thank you for explianing to me a bit about AJAX I really need to educate myself with how to use it.