473,395 Members | 1,468 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

HTTP header insertion using javascript

3
I would like to use javascript (or something similar) in my page in order to make the browser send a specific HTTP header (let's say the header 'X-Try:' with some value). I would like to do it on every subsequent request to the same domain (The domain that originally sent the javascript to the client).
Can I do such a thing? and if yes - how exactly ?
Jul 19 '08 #1
6 18111
rnd me
427 Expert 256MB
are you talking about a request header, or a response header ?

you can set request headers in ajax.

you can mimic response headers with meta tags, splicing them into the response and then doc.writing the output, but that's about as good as you can do with just javascript.
Jul 20 '08 #2
spsmn
3
are you talking about a request header, or a response header ?

you can set request headers in ajax.

you can mimic response headers with meta tags, splicing them into the response and then doc.writing the output, but that's about as good as you can do with just javascript.
I'm talking about injecting request HTTP headers in all subsequent requests that are destined to the same domain as the domain that initially sent that javascript.
I want to embed in my javascript (the one I sent as a response for request#1) a piece of code that will add a specific HTTP header in all the next requests originated from that javascript page.
I prefer using javascript to do that...
but, if there's a way to do that in ajax - can someone elaborate on that ?
Jul 20 '08 #3
dmjpro
2,476 2GB
I'm talking about injecting request HTTP headers in all subsequent requests that are destined to the same domain as the domain that initially sent that javascript.
I want to embed in my javascript (the one I sent as a response for request#1) a piece of code that will add a specific HTTP header in all the next requests originated from that javascript page.
I prefer using javascript to do that...
but, if there's a way to do that in ajax - can someone elaborate on that ?
What type of HTTP header you want to add?
And how to add HTTP header before Ajax call, go for Google.
Jul 20 '08 #4
spsmn
3
What type of HTTP header you want to add?
And how to add HTTP header before Ajax call, go for Google.
I would like to add the HTTP header "X-Try: blabla" inside each subsequent request .
I would like it to be placed somewhere inside the HTTP header of a regular request coming out of the client's browser
Jul 20 '08 #5
acoder
16,027 Expert Mod 8TB
Use the setRequestHeader method of the XMLHttpRequest object.
Jul 20 '08 #6
rnd me
427 Expert 256MB
you can use ajax, and a fullscreen iframe to do it.


lets say you had an iframe (id="iframe1") styled to take up 100% of the screen: no body margin or padding:








Expand|Select|Wrap|Line Numbers
  1. function el(tid) {return document.getElementById(tid);}
  2.  
  3. function IO(U, V) {//customized for post...
  4. //LA MOD String Version. A tiny ajax library.  by DanDavis
  5.     var X = !window.XMLHttpRequest ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest();
  6.     X.open(V ? 'PUT' : 'GET', U, !1);
  7.     X.setRequestHeader('Content-Type', 'text/html')
  8.  
  9.     X.setRequestHeader('X-Try', "blabla");
  10.  
  11.     X.send(V ? V : '');
  12. return X.responseText;}
  13.  
  14. var doc = el("iframe1").contentWindow.document
  15. doc.write( IO("page1.htm"));
  16. doc.close()
  17.  
  18.  
Jul 20 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Lian | last post by:
Hi all, Is there any way to get all the information in HTTP header? I want to get a item called "Referring URL" in HTTP header. I find the information is not contained in the environment global...
13
by: long5120 | last post by:
I am trying to use webpage with javascript to check if a web server is responding. I was thinking of using 2 frames. Frame1 will have the site, and the Frame2 will be a status bar (not really...
5
by: lefebvre | last post by:
I am writing a website for a real estate client, and am using Dynamic HTML menus. In doing so, the way the browser moves to the next page is via the onclick property and changing the location.href...
3
by: prc11375 | last post by:
I'm trying to access http header parameters with javascript. Can anyone direct me to js libs to suit the purpose or provide some guidance? Thanks
0
by: Dean Hallman | last post by:
Hello, I am developing a BHO that should add a custom HTTP header on a specific domain only. Don't want the header globally, otherwise I could just add a registry key. So, on...
2
by: mngibson | last post by:
Is there any way to access arbitrary http header information through javascript? For example, if I wanted to obtain content-length? I suspect not, but I'm not too knowledgable on js. Thanks,...
8
by: ronen.chen | last post by:
I noticed that some sites use <script src='fineName.js?ver=XXX'></script(even google) Someone told me that it's for script changes, means - if the file in server has been changed than the new XXX...
1
by: Andyza | last post by:
With reference to the ASPFAQ 2161 article - http://classicasp.aspfaq.com/general/how-do-i-prompt-a-save-as-dialog-for-an-accepted-mime-type.html Does the 'Content-Disposition' code work if the...
7
by: vunet.us | last post by:
Can I get the name of a referral page using JavaScript? Just really wondering...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.