Link to home
Start Free TrialLog in
Avatar of zorba111
zorba111

asked on

use javascript to request a page

We have a situation where were are in a form, but want a sub form to post (which I'm told will not work in HTML).

So... what if instead of using a subform, we provided a button which hooked into some javascript which requested the required page (in this case the same page).

Now I know javascript can request a page be launched in a new window, but how about in the same window/tab ?

i.e. the javascript replicates a HTML form/submit cycle ?
Avatar of zorba111
zorba111

ASKER

 window.location.replace("http://www.w3schools.com")

CAn this be used to supply parameters also, e.g.

  window.location.replace("http://www.w3schools.com?nameA=valueA&nameB=valueB")

?
window.open(URL,name,specs,replace)

Parameter       Description
URL       Optional. Specifies the URL of the page to open. If no URL is specified, a new window with about:blank is opened
name       Optional. Specifies the target attribute or the name of the window. The following values are supported:

    * _blank - URL is loaded into a new window. This is default
    * _parent - URL is loaded into the parent frame
    * _self - URL replaces the current page
    * _top - URL replaces any framesets that may be loaded
    * name - The name of the window

>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

thanks w3schools....

_self looks promising - am I on the right track ?

cheers!!
ASKER CERTIFIED SOLUTION
Avatar of Sinistra_D32
Sinistra_D32

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@Sinistra_D32:

thanks!

note to self (thnks wikipedia)

XMLHttpRequest (XHR) is a DOM API that can be used inside a web browser scripting language, such as JavaScript, to send an HTTP or an HTTPS  request directly to a web server and load the server response data directly back into the scripting language.[1]  Once the data is within the scripting language, it is available as both an XML document, if the response was valid XML markup,[2]  and as plain text.[3]  The XML data can be used to manipulate the currently active document in the browser window without the need of the client loading a new web page  document. Plain text data can be evaluated within the scripting language to manipulate the document, too; in the example of JavaScript, the plain text may be formatted as JSON by the web server and evaluated within JavaScript to create an object of data for use on the current DOM.

XMLHttpRequest has an important role in the AJAX web development technique. It is currently used by many websites to implement responsive and dynamic web applications. Examples of these web applications include Gmail, Google Maps, Bing Maps, the MapQuest dynamic map interface, Facebook, and others.