I have this method for downloading a script:
var script = document.createElement('script');
script.setAttribute("src", url);
document.getElementsByTagName("head")[0].appendChild(script);
This gives me a GET like this:
GET http://127.0.0.1:17315/Scripts/abc.js HTTP/1.1
However I need to add a header:
Authorization: Bearer Ipnsfm9h1MWYIM0n1ng
Can anyone tell me how I can add a header when I am using Javascript to perform the GET?
Let's say you have a Javascript function that calls a web service method. So that webservice completes and calls a callback function, which has the result.
How do I get that result back into the original function that called the web service method? Essentially, I'm trying to "synchronize" an asynchronous call.
Given a javascript array and one of its members, how to retrieve the member index without having to compare the contents of the member against every other member in the array?
if I put a div in the head and display:none, than use javascript to display it, will this work?
Edit:
I have stuff loaded in ajax. And as my ajax changes the "main" portion of the site, I want to change the meta-tags as well.
When we open plain swf in browser, we are able to control the swf file by right clicking, the available control are: zoom in, zoom out, quality, rewind (previous frame), forward (next frame), and print. Is it possible to trigger those control using javascript especially jquery?
Thanks.
The following does not work:
var js_str= '<?php echo $str_from_server; ?>';
The problem is that, $str_from_server can contain any characters. If it contains single quotes or line breaks or others, the above code will break. And I do not have access to the server-side code. What's the easiest way to "escape" the contents of $str_from_server into a javascript string, and then it can be restored later?
I am making websites I refer to from my site load up in a frame (similar to google images). But I also want to give users the ability to break out of that frame. Like with google image's "Remove Frame" link at the bottom right corner of their frame. How can I do this possiblyusing Javascript?
I need a log function in my javascript but it needs to be base 10, I can't see any listing for this so I'm assuming it's not possible... any math wizards out there know of an approach for this? Or maybe I'm missing something and there is a way?
I am trying to create a table of 100 random numbers, the random numbers are from 0 to 100. I need to display the 100 random numbers as a 10 by 10 matrix in HTML, using JS and jQuery. The code that I have been working on displays the last array 10 times. Here is the code:
<html>
<head>
<title>My Web Page</title>
<script type = "text/javascript" src = "http://code.jquery.com/jquery-1.8.2.min.js" />
</script>
</head>
<body>
<h1 id = "randData">Randomize Data</h1>
<button id = "myRandomizeBtn">Randomize</button>
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
<p></p>
</body>
<script type="text/javascript">
$("#myRandomizeBtn").bind("click",randomizeHandler);
function randomizeHandler(evt)
{
var n = 10;
var data = new Array();
for (var i = 0; i < n; i++)
{
for (var j = 0; j < n; j++)
{
data[i,j] = Math.floor(100*Math.random());
$("p").text(data);
}
$("br").text(data);
}
}
</script>
</html>
I'd like to use Javascript to replace all instances of \u009 in a string
This doesn't seem to be working: .replace(/\u0009/g,'');
Do I need to escape something?
Modifying a SnapPages theme, meaning I only have access to the CSS stylesheet. I would like to insert some javascript in the header of the site in order to use TypeKit for styling typography. Is there anyway to do that from CSS?
hi,
is there any javascript library for resizing the images according to browser window sizes ?
I need to consider all cases (vertical / horizonal image, vertical / horizonal browser window)
N.B. The image scale has to be the same! (no distorsions)
thanks
How to find all files in directory? I have HTML page in some directory. Using JavaScript I want to get all existing files in some subdirectory (get file names or relative links to them)
Hi guys,
about Validations,
are Javascript and ASP.NET validation used for the same purpose?
if yes, which one do u recommend?and simple explanation please,
thanks
Can I share javascript libraries I've loaded in part of my website, with other components ?
For example, I'm loading a node of my drupal website into a lightbox (rel="lightmodal"), so it is not a frame.
I would like to have access from the content of the lightbox to qtip.js library (at the moment I'm using its functions but it doesn't find the library, so it doesn't work..)
thanks
SO i totally understand why we should namespace in javascript, but is it mainly for organizational purposes and to keep the global namespace uncluttered?. Does namepacing actually help in performance of the browser/JS engine.
Just wondering what your thoughts were.
Thanks
i am using googleBar on my gmap application, after i manipulate the results of the search i want to clear the results of the search, but without using the clear results button.
i want to clear the results with from my JavaScript function.
how can i do that?
For example: I want to accept or reject a photo.
The input button for accept and the form is:
<form method="post" action="viewRequests.php">
<input type="submit" onClick="showAlertBox()">
</form>
showAlertBox() is a javascript function which shows a confirmation dialog with Yes or No. If I choose No then the form submission should not be triggered.
what to do in this case