I have this function
window.open("<%=mcrforHyperLink%>&fromDate="+fromDate+"&interfacen="+interfacen+"&interfaceid="+interfaceid+"&toDate="+toDate,'name_' +Math.floor(Math.random()*11),'height=680,width=900');
This is not in IE , but working fine under Mozilla .
please help .
Internet Explorer can't handle window names that include a space. You don't have one, but I'd bet it also has problems when they include a . character (which you are generating with Math.random`). Make sure your name contains just alphanumerics.
Please explain why you are generating a random name for the window.
If you were to re-use it elsewhere I could understand.
This will do exactly the same unless there is something I have missed
window.open("...",'_blank','height=680,width=900');
(the ... is your url)
Also please notice that most modern browsers may BLOCK your window open unless instructed otherwise. If the url is from the same domain as the page with the script, I suggest you ajax it into the page you are on.
Related
I've seen several threads about reading contents, but nothing on writing to noscript.
$('body').append('<noscript><div></div></noscript>');
In Chrome and IE9 I get a noscript-element with a empty div inside like I expect, but in IE7 and IE8 I just get a empty noscript-element without the div inside.
Example: http://jsfiddle.net/cEMNS/
Is there a way to add HTML inside the noscript-tag that works in all browsers? What I need is to add some tracking code into a noscript-element at the end of the page, but the info I need isn't available until after document ready.
Edit: I'm getting a lot of comments on "why". It's some poorly done tracking library that requires this. We don't have access to the code to change it. Regardless, I find it interesting that it works in some browsers and not in others since jQuery was supposed to work equally in all browsers. Is it simply a bug?
Edit2: (2 years later) Adding a noscript on the browser doesn't make sense, I know. My only excuse not the question the task I had was because of lack of sleep, like everyone else in the project. But my rationale was that jQuery should behave the same on all browsers and someone might want to do this on the server.
Regardless of the tracking code, what you are doing (or are required to do) makes no sense!
Why? There are two cases possible here:
user has JavaScript enabled in which case the NOSCRIPT get's inserted into the DOM but is ignored by the browser (does nothing)
user does not have JavaScript enabled, NOSCRIPT does not get inserted and does not "execute"
The end result of both cases is that nothing actually happens.
Just an idea: You could try giving your noscript tag an ID, and then try to use native js.
for example:
$('body').append('<noscript id="myTestNoScript"></noscript>');
document.getElementById('myTestNoScript').innerHTML = '<div></div>';
I would claim that if it does not work with native js, it will not work with any library (feel free to correct me on this one).
I tried following simple HTML code:
<html>
<body>
<noscript>I'm a noscript tag.</noscript>
</body>
</html>
Then I did analyse this with IE8 (in IE7 mode) and his integrated code insprector. Apparently the IE7 checks are script allowed. If so he declared it as empty. And empty tags will be ignored. Unfortunatly I could not try that with disabled script option, because only the Systemadministrator can change the settings (here at my work).
What I can assure you, the noscript does exists. If you add
alert($('noscript').size());
after the creation, the result will be 1.
I don't understand this at all. Here is some Javascript code that works in every browser but IE 9. It is called from a Flash movie using ExternalInterface, and is meant to dynamically resize the movie in the DOM if the size of the movie changes internally
function vResizeFlash(swfId, ht) {
document.getElementById(swfId).height = "100%";
document.getElementById('flashContainer').style.height = ht + "px";
}
But it works fine if I alter the document.title:
function vResizeFlash(swfId, ht) {
// IE 9 won't run the rest of this function unless
// we go through the charade of changing the document title.
if (navigator.appName.indexOf("Microsoft") != -1) {
var docTitle = document.title.replace(/^(.+?)\s*$/,"$1");
document.title = docTitle + " ";
}
// Well-coded browsers begin here
document.getElementById(swfId).height = "100%";
document.getElementById('flashContainer').style.height = ht + "px";
}
Here I simply trim any white-space from the right side of the document.title, then add a single white-space character to it. Suddenly the following lines get executed. Note: there are other ExternalInterface calls on the page, and all of them work fine, even in IE 9, so it's not a Flash/IE 9 problem.
I stumbled on the fix because I was altering the title to show the function arguments (as a quick debugging test), just to make sure the function was getting run. And suddenly the code worked. Take it out? Doesn't work. 100% reproducible.
Anybody know why this absolutely stupefying behavior takes place?
UPDATE
#c69 has posed the question: "Maybe its IE9's dead code remover?"
I didn't know about this, so I went and Googled and found this article on the topic, as well as some discussion of it elsewhere. I don't know enough about it to evaluate how this would affect a two-line Javascript function, however, especially since one of the lines does have a referent on the page (although it is late-loading through the SwfObject code). Still, it would be a pretty bad bug for a code "optimizer" to remove lines of code it deemed unnecessary because it doesn't understand how they are called. And if it did fail to understand how the lines are called, how does inserting a line making a bogus change to the document.title render that code suddenly "necessary"?
UPDATE 2
Another piece of the puzzle This may have something to do with IE 9's compatibility mode. The page starts out in IE 9's standards mode.
Now, if I turn on IE's compatibility mode,
the problem goes away without using the above hack. Turn it off, and the problem returns (if no hack present).
But when I tried to make a simple test using the exact same HTML (minus a couple of JSP tags) and a stripped down SWF that only contains the resize code and the tools to test, everything works fine. In that case, however, no compatibility icon is displayed at all.
We're using Tomcat 6.0.32. I'm not aware that we are using any special headers, and there are no meta tags regarding IE compatibility mode (in either the main app or in my test app).
like InvertedSpear mentions, check your doc type out, i've had problems with IE9 recently and most of it boiled down to the Doc type tags triggering a compatability mode i didn't need, the same can be true of the meta tags so it might boil down to your Meta tags.
You can always impose a working compatibility mode using the links below too.
from: http://evolpin.wordpress.com/2011/02/25/ie9-compatibility-and-the-meta-tag/
I’ve discovered that this is indeed documented by Microsoft…
http://msdn.microsoft.com/en-us/library/cc288325(VS.85).aspx
“The X-UA-Compatible header is not case sensitive; however, it must appear in the header of the webpage (the HEAD section) before all other elements except for the title element and other meta elements.”
Whenever I see something like this happen in any language it's because there is other code that has a bug. As you pointed out your simple case doesn't produce the problem. Try removing other code a few lines at a time until the problem disappears - the last removed code should contain the problem.
Cheers
I use :
Window.showModalDialog(...)
to open a dialog window,
I want show some HTML code in this window, but I don't have a file. (Can't use URL to visit)
like show "hello world!" in this dialog window.
Can I do it?
Interesting question!
I'm not an expert in modal dialogs, but I don't think you can, because it's in the nature of a modal dialog to block any further code from being executed until the window is closed again.
I thought about using a data: URI that you could use as the first argument to showModalDialog instead of a normal URL:
window.showModalDialog("data:text/plain;base64,SGVsbG8sIFdvcmxkIQ%3D%3D" ....);
but according to the MSDN page on data: URIs, that will not be supported in Internet Explorer. (see the "Remarks" section on the linked page)
It might work in Firefox, though: More on data URIs at Mozilla Developer Central
Update: It works in Firefox: JSFiddle but, as expected, not in IE. You only get a blank window there.
Good question and answer. (+1)
I just thought I'd add, that if you do need to enter HTML into a modal dialog, you may want to look into using a Javascript library to accomplish it. I've used Dojo's "dijit.Dialog" several times with HTML, including images, form controls etc... You can style it however you like, and it works well cross-browser.
You can check out a few example of dijit.Dialog's use over at DojoCampus.
Cheers.
UPDATED
I have a page where i upload an image to crop which opens a window with the required functionality, it works absolutely fine as per below given script, but it doesn't work with IE
<script>
window.open('http://mymachine/mysite/crop.php?bgimagecode1=1281439586.jpg&x=728&y=364&id=30&bannersize=1x2&osCsid=','mywindow','fullscreen=yes,scrollbars=yes');
</script>
please help
Maybe you have IE set to block popups? You have to whiteflag the domain or it won't open. I would check your preferences.
If you are using PHP to generate this string, you should be using urlencode to make sure the URL's querystring is valid.
Don't set the second parameter. It doesn't work in IE... just leave it empty.
window.open('". HTTP_SERVER . "/crop.php?bgimagecode1=".$realname."&x=".$w."&y=".$h."& id=".$_POST['categoryId']."&bannersize=".$_POST['size']."&osCsid=".$_POST['sid']."','','fullscreen=yes,scrollbars=yes');
More info in a previous thread...
I need to create a popup in my web app to load a unity file. For that I'm using Javascript's Window.Open.
I don't want the user to see the popup's URL or to give him the chance to alter the URL.
According to this link:
http://javascript.about.com/library/blpopup10.htm
"location can be set to yes or no to
indicate whether or not the new window
should display the location or address
bar. Note that this is a
recommendation only as some browsers
such as Firefox can disable this to
ensure that the toolbar will always
appear. In IE7 this setting controls
whether or not the navigation bar will
be displayed as the address bar will
always display in that browser. "
There is no longer a chance for me to remove the location from IE7.
I've tried to set it to location =no (and =0) and in fact it doesn't work in IE7/8 or Firefox. It does in Safari.
Since we all have had those boring spam popups that don't have the URL bar (called Location bar) that's a proof that there must be a way!
Hope that someone has the right answer.
Thank you.
Regards,
Bruno.
what about inline pop-ups? You can write your own code or see this: http://docs.jquery.com/UI/Dialog.
I dont use standard window.open javascript function at all, as in IE 8 it's IMHO impossible to hide location bar.
Inline (I mean html) dialogs have more features than window.open.
Hope it helps.
No, there is no way to get rid of that bar in IE7 - this change was brought in as a security measure to help combat phishing.
As Feryt says, you can use inline popups, which is probably a better solution anyway.
Instead of window.open() use window.showModalDialog()
You can use Chromium Application Mode which works on all browsers expect Safari and Firefox.
I don't know the exact commands/paths for linux and mac, but you can search a bit.
run this code on cmd
cd "C:\Program Files\Google\Chrome\Application"
chrome.exe --app=https://yoursitehere.extension
or
Create a shortcut:
"C:\Program Files\Chrome\Application\chrome.exe" --app=https://yoursitehere.extension
For other browsers change the chrome location with the browsers' location.
By the way, this feature can be removed because of the security vulnerabilities.