I would like to achieve that when clicking in an image, in the div where this image is, a div with other content from another .html is loaded, but I can't get it done.
If I do, the following, it works perfectly:
$('#windows_link').click(function(){
$('#apps_container').html("Hi!");
});
But if I do the following, it does not work; it doesn't do anything actually:
$('#windows_link').click(function(){
$('#apps_container').load('windows_apps.html #apps_container');
});
Any help, please?
Thanks a lot in advance!
When you're local any other HTML path is treated as another domain in certain browsers (Chrome is on the list). That means any AJAX request (what .load() does underneath) you attempt will be blocked by the same origin policy.
What you have will likely work fine...just not locally, in Chrome.
You can verify this by testing in another browser like Firefox, or by launching chrome with a command line switch to disable this safety feature (only for testing!, turn it off after):
chrome.exe --disable-web-security
If the first try works correctly, i assume the problem is here
.load('windows_apps.html #apps_container');
When you click the link, do you see a call in your .net panel of firebug or of your debugging console(does the ajax call complete succesfully)?
Is windows_apps.html in the same folder of the page script that calls it?
is there a div called apps_container into that page?
Related
I am facing a really weird problem. I am calling window.print() from a javascript file. This is working fine in Safari, IE, Firefox... and until two hours ago it worked in Chrome, too. (Version 29.0.1547.57)
I did not change anything essential in my javascript file (really - I just removed some comments...), but what now happens is really weird: In Chrome, the print dialogue does not open when window.print() is called. Nothing happens. But then, when I press reload, the print dialogue opens immediately.
The behaviour in the other browser did not change. And while debugging in Chrome I can see that window.print() is called as expected and the script goes on after that. Only the print dialogue is not shown until pressing reload.
Has anybody ever experienced something like that? I also tried to call window.print() in setTimeout(), but this did not change anything. When I debug the content of the page which shall be printed appears to be perfectly loaded.
I am sorry to ask, but I did not find anything while researching. Any help would be appreciated!
Thank you!
Wasiim is right, there is a Chrome bug where window.print() does not work when there is a <video> tag in the DOM. I solved it by calling this function:
function printPage() {
window.print();
//workaround for Chrome bug - https://code.google.com/p/chromium/issues/detail?id=141633
if (window.stop) {
location.reload(); //triggering unload (e.g. reloading the page) makes the print dialog appear
window.stop(); //immediately stop reloading
}
return false;
}
From my experience this is due to continued background traffic, e.g. ajax calls and the like that prevent Chrome from feeling the that page is loaded completely. The reload breaks all traffic and thus the print dialog pops up.
This is a particular gotcha in Visual Studio 2013 where BrowserLink continually ticks away in the background.
This can be tested by disabling BrowserLink via the setting below:
<configuration>
<appSettings>
<add key="vs:EnableBrowserLink" value="false"/>
</appSettings>
</configuration>
I have exactly same problem with Chrome. You need to manually reload page:
Print
If by any chance someone is using VS2013 with chrome, this problem is caused by the BrowserLink funcionality.
see SO answer here
Similar behavior in Safari. It is caused by opened HTTP request(s) on background.
When any HTTP request is in progress, window.print() is executed successfully, but no dialog is opened!
You will have this issue, when you use a long polling (for server push). Because client will have already opened HTTP connection for a long time, window.print() will never work.
I am most certain you are experiencing this issue because you have a video element on your page - most probably an MP4.
If you disable this video / or have an OGV video instead, the printing should work fine.
It is a bug in chrome itself due to limitations of Chrome's video implementation. It is also important to note that if the user prints manually with ctrl-p / cmd-p, print functions correctly
http://code.google.com/p/chromium/issues/detail?id=141633
Hope this helps :)
How is this site triggering its popup while bypassing Chrome's pop-up blocker?
http://undertexter.se/
I thought pop-up blockers only allowed window.open if it was triggered by a user action but that's not the case here so how are they doing it?
OUTDATED
Origin resources and fiddles do not work anymore.
I figured out that there is an popup opening in chrome if you visit the Website first time (empty cache) and click somewhere on the document.
After a refresh and a click on it again nothing will happen if cache wasn't removed.
So lets start the game of reverse engineering...
Took the script from
http://undertexter.se/ and startet refuscation.
After a few steps I got the following code and I think this is not planned by browser manufactures to support something like this.
Now I wish you a lot of luck to use that for your own but I think it's evil.
Look on js fiddle for the result:
Its the reverse of:
http://www.wigetmedia.com/tags/undertexter.se.js
http://jsfiddle.net/W9BdS/
Tested on my own server, This opens up http://google.com in a new (standalone) window in Chromium 28 on Ubuntu 12.04. Adblock is active.
<script type="text/javascript">
document.addEventListener('click', function() {
window.open('http://google.com','...','width=1080 height=640')
})
</script>
try this using JQuery
$('#yourCotrolId').on('click', function() {
window.open('yourLink','...','width=1080 height=640')
});
window.open is blocked by modern browsers when called not in a click event handler.
I faced this myself while using Rails' format.js responses and wrote a small plugin that makes showing JS popups as simple as calling window.open():
Popup("<div>Hello world</div>").show('up')
You could use the .trigger method for simulating an user action:
Click
$('a').trigger('click');
.trigger() can not be used to mimc such native browser events, you can use .simulate() from simulate.js to mimic such events.
include simulate.js in your file and use,
$('a').simulate('click');
Onclick of a anchor tag i am giving window.print(); call and I get the print pop-up. But on the click of print I get the following script error.
An error occurred in the script on this page.
Line: 2115
Char: 1
Error: Your file waiting to be printed was deleted.
Code: 0
URL : res://ieframe.dll/preview.js
Do you want to continue with the script on the page(yes/no buttons)
May what ever you click Yes/No I don't get the print or in IE8 i get a blank print.
Firefox prints fine. But, fails in IE9.
Can some one help me on this one??
You can also get this error in IE10 if you are calling window.close() immediately after window.print(), especially if your DOM is large. My guess is that the page has not finished rendering when IE10 executes the window.print() call.
You can therefore get around this issue by:
Calling window.close() within a hover event on the page. A print dialgue will steal the user's focus, so the hover event wont fire until the user has finished dealing with the dialogue. We found this to be the best solution.
Not calling window.close() at all for IE10 clients
As window.print() does not have a callback, calling window.close() after an arbitrary delay. I wouldn't recommend this as it will be unreliable
Go "nuclear" with this answer, which loads the html into a hidden iFrame before printing, sidestepping the need to call window.close()
Follow this two Microsoft help articles:
http://support.microsoft.com/kb/973479
http://support.microsoft.com/kb/2652062
At least it seems to be a problem with print driver and or problems with add ons installed in the IE. An other solution is to be uninstall IE 9 and reinstall it.
I ended up replacing/upgrading the printer driver on the server end, removing the printer on the desktop client and recreating the printer via the handy UNC path (double \ which doesn't show here) \server\printer" add method.
I have a situation where I'm inserting javascript generated HTML code into a DIV. One would think this would be a no brainer, but for some reason, once the code is in, the status bar and tab loading graphics start up in both browsers and never stop again. The page continually appears to be loading data, but in reality, there's nothing more to load. Any idea why this may be happening? Solutions? I appreciate any help. Thanks!
Install the Firebug plug-in for Firefox. Open it up and got to the NET tab. That will allow you to see your network activity. Something on the server may be stalling. This will help you find it.
I want to debug a javascript file that is embedded in the HEAD element.
I navigate to the site, see the code, and make a breakpoint:
(source: deviantsart.com)
But when I click on Reload, the script disappears and it doesn't stop at the breakpoint:
(source: deviantsart.com)
Debugging was working earlier so I know it works in general. What do I have to do so that Firebug always debugs my script?
I've noticed this behaviour before as well. It seems that it can happen if you refresh the page while the debugger is running (i.e. after you've hit your breakpoint and are stepping through code). This is far from conclusive, just something I've casually observed over time.
Also, I try to avoid having multiple tabs open with firebug active, as it seems to get confused.
Edit: just thought I'd add that I've seen this manifest itself in a few different ways:
the external script file does not appear at all in the scripts panel.
the external script file appears but firebug doesn't "see" it. You know this has happened because the line numbers beside the code where a breakpoint can be set won't be highlighted (used to be green but now appear to be just a darker shade than other lines). I've seen this happen with inline javascript on a HTML page (horrors!) as well.
the external script file is there, but you can only see a single screen full of code. Where "screen full" is the firebug panel viewport.
shut down firefox and then restart. sometimes firebug gets confused. also make sure you have the latest version.
You need activate the script tab
I'm not sure that having a <script> inside <head> (as opposed to, inside <body>) is actually legal HTML. If it's not, as I suspect, you can't fault Firebug for not supporting it well...!-)
The bugs in script processing that I know about are 1) jquery dynamic loading of scripts fails, 2) new Function() cannot be seen, 3) some kinds of document.write() cannot be seen.
Firebug processes script files in series with Firefox. This means that Firebug must be active when the page loads and it means that any exception in the path will cause the files to be mis-processed. If you opened firebug before loading and you still see problems, then the most likely fix is to install Firebug in a new Firefox profile. This causes you to get a completely fresh set of default options and you run Firebug without other extensions. As you re-add other extensions, look for problems in seeing scripts: then maybe you will discover what extension is interfering with the code path for processing scripts. I know this is a pain in the neck, but so is JS debugging without source ;-). We are working on testing with more Firebug and Firefox extensions installed to try to reduce these problems.
In our case it was the bundling of JS files.
It is not only FireFox, it is same for Chrome.
We moved the file out of the bundle and put it on the page where it needed to be referenced and it started working like charm.