Hi all i am writing a Rails application and i include some link_to_remote links
The generated code is
Test
That works perfectly fine on Safari and Firefox but when i try to click the link on IE7 and Opera it does not even hit the server.
Any hints ?
Use a fully qualified URL: http://.....
This is a bad practice to include all of this code in the <a href> tag anyways. I suggest you make a function such as:
function doAjax(url)
{
new Ajax.Request(url, {asynchronous:true, evalScripts:true});
return false;
}
in the javascript code. And change the url to say instead:
<a href="#" onclick="return doAjax('/b10/categories/games?category=Action');">
Test</a>
Related
I have the following bookmarklet:
javascript:findlink=document.getElementsByClassName(%22download_link%22)[2].href;window.open('https://myfiledrive.com/users/files/add?url='+findlink,'_blank');void(0);
Example:
<a class="download_link" href="example.com/pdf1.pdf">
<a class="download_link" href="example.com/pdf2.pdf">
<a class="download_link" href="example.com/pdf3.pdf">
Basically, it searches the currently active page, for the third iteration of an tag with the class "download_link", and stores it in the variable "findink",
Then it loads 'https://myfiledrive.com/users/files/add?url='+findlink
In the above example it should load:
https://myfiledrive.com/users/files/add?url=example.com/pdf3.pdf
but what ends up happening is that this gets loaded:
https://myfiledrive.com/users/files/add?url=example.com/pdf3.pdf?url=example.com/pdf3.pdf
so basically it's duplicating url=
What am I doing wrong? Thanks.
The url param shouldn't be duplicated. You're not appending to findlink or anything. You can try the snippet below, it's exactly as you've posted.
Chrome will block the popup, but if you read the error message, there's no duplication going on:
Blocked opening 'https://myfiledrive.com/users/files/add?url=https://stacksnippets.net/example.com/pdf3.pdf' in a new window because the request was made in a sandboxed frame whose 'allow-popups' permission is not set.
url is only in there once no matter how many times I click.
<a class="download_link" href="example.com/pdf1.pdf">1</a>
<a class="download_link" href="example.com/pdf2.pdf">2</a>
<a class="download_link" href="example.com/pdf3.pdf">3</a>
download
How do I open PDF on a new tab, target="_blank" alone does not work it still open the pdf in the same tab.
Method-1 : HTML
<a target="_blank" href="http://your_url_here.html">Link</a>
You can simply do that with setting target="_blank" for an example check this
More Details
Method-2 : Javascript
<a onclick="openInNewTab('Your URL');">Something To Click On</a>
function openInNewTab(url) {
var win = window.open(url, '_blank');
win.focus();
}
Without your code is hard to tell what's wrong but did a fast test and this worked for me..
<a target="_BLANK" href="pdf/your_pdf.pdf">YOUR PDF</a>
You have to know: "_Blank" is not working as a "new tab" on every browser.
To do that, you have to use js like this:
Lnk
(it will work on any browser, "_blank" will not)
EDIT: Of course, here the "link" in window.open will be the path to where your PDF file is stored.
EDIT2 (thanks to vlaz): Yep, it will work on any browser if JS is enabled, if he his not it will not.
So on the GitHub documentation for Ratchet 2.0.2 I found the following statement.
Script tags containing JavaScript will not be executed on pages that
are loaded with push.js. If you would like to attach event handlers to
elements on other pages, document-level event delegation is a common
solution.
Can someone please spell out exactly how to get a custom <script> to execute after being loaded by Push.js?
On my first page, I have a Table view, with several links to other pages, one of them being a link to a second page with a Twitter Feed widget on it.
<li class="table-view-cell media">
<a class="navigate-right" href="Twitter.php" data-transition="slide-in">
<span class="media-object pull-left icon icon-person"></span>
<div class="media-body">
Twitter Feed
</div>
</a>
</li>
The second page only contains the twitter feed widget code. When I browse to this page directly (without being loaded by Push.js) everything loads correctly, but when it is loaded via Push.js, the script is not executed.
Can someone please explain what I need to do to get this script to execute after being loaded by Push.js? I've searched Google, Stack Exchange, and Github\Ratchet issues and have not been able to find a good example of how to accomplish this.
One solution would be to add data-ignore="push" to the link, but I want to know how to do with WITH push.js.
<div class="content">
<a class="twitter-timeline" href="https://twitter.com/XXXX" data-widget-id="XXXX">Tweets by XXX</a>
</div>
<script>
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");
</script>
EDIT: below was how I originally solved this problem, which worked fine, but I came up with a better solution, which I posted as the answer to this question.
I finally figured it out.
On your first page, you need to do the following...
var checkPage = function(){
//Only run if twitter-widget exists on page
if(document.getElementById('twitter-widget')) {
loadTwitterFeed(document,"script","twitter-wjs");
}
};
window.addEventListener('push', checkPage);
checkPage() will execute for every time a new page is loaded via push.
Just made a change for Ratchet.js to make individual js works for each page more elegant.(https://github.com/mazong1123/ratchet-pro)
By using the new ratchetPro.js, we can do followings:
(function () {
var rachetPageManager = new window.RATCHET.Class.PageManager();
rachetPageManager.ready(function () {
// Put your logic here.
});
})();
I'm coming across an odd issue, I've had this web application running for a few years now and only since people started using IE9 they get the below error. Has been working fine in IE6, 7 & 8.
'submit' is undefined
The code being used is this:
<a name="SaveButton" id="SaveButton" onclick="javascript:document.getElementById('action').value='validate'; submit();" href="#" >Save</a>
Any suggestions or help is greatly appreciated.
Update:
When I change it to this it seems to work find in IE9.
<a name="SaveButton" id="SaveButton" onclick="javascript:document.getElementById('action').value='validate'; formname.submit();" href="#" >Save</a>
*formname is the name of the form being submitted.
submit function in JavaScript is valid for form element. So this code is invalid , and only somehow works in older internet explorer.
For buttons or inputs the correct syntax is this.form.submit()
The cause of the problem was due to IE9 not liking the submit() function call coming from an A HREF tag, it should really be used in an INPUT or BUTTON tag.
The way around this due to not being able to modify the majority of the codebase was to add in the form name just before the submit function call like below:
formname.submit();
Final, working code:
<a name="SaveButton" id="SaveButton" onclick="javascript:document.getElementById('action').value='validate'; formname.submit();" href="#" >Save</a>
The onclick function now works in all IE versions it used to and IE9.
What is wrong on this syntax:
PHP
echo '<li onMouseOver="" onMouseOut="document.getElementById(\''.$boxrow.'\').style.display=\'none\';">';
And on HTML page source code:
<li onmouseover="" onmouseout="document.getElementById('evidence').style.display='none';">
IT is working fine, but scripts after this wil causing errors, if I remove this script everything working fine.
First what is below this script and stop working is:
header("Location: index.php?module=service&no=".$_POST['id']."&"); and next after ...
PHP header redirection only works if you still didn't parse any code on your page. Try redirect by javascript instead.
Also it's a better practice not to use inline javascript. Better:
EDIT:
window.onload = function() {
li.onmouseout=function(){
document.getElementById('evidence').style.display='none';
};
};