this should be pretty easy but I'm having problems with making it work right.
This is for a small warehouse that delivers objects. when someone orders something it appears on a page wich is generated automatically. It is an index.php this is the code that contains the print link :
<tr class="">
<td width="244" align="left">
<p style="padding-left:5px; ">
<strong>1.</strong>
<strong style=" font-weight:bold; font-size:12">Client Name</strong>
<br/>
<a href="http://site/orders/order.php?id_comanda=15284656"
target="_blank" onClick="this.blur()">15284656 - auto</a>
<br />
<a href="marfa-pregatita.php?nr_aviz=401599413&nr_disp=18129704&act=2"
target="_blank" onClick="this.blur()">printing link</a><br>
<span style='color: #FF0000'>times printed :
<span style='font-weight:bold';font-size:10pt>1</span> x</span>
</p>
<a name="df_18129704"></a>
</td>
there are multiple codes like this on the page numbered from 1 to how many are there. The "printing link" needs to be opened and printed for everyone of this orders. I am quite new to java coding. How can this be done? the printing link changes only with the "nr_aviz=401599413&nr_disp=18129704" just the actual numbers change. Please help! I want this to run as an addon on chrome.
If you want to develop a chrome extension, see the Chrome Extenstions developper documentation to get started. You'll have to write Javascript code (not Java which is a very different language).
You can select every printing links by using Javascript CSS selectors API, like so :
// selects links (<a ...>) where attribute "href" starts with "marfa-pregatita.php"
var selector = 'a[href^="marfa-pregatita.php"]';
var links = document.querySelectorAll(selector);
// for each link, click on it
for (var i=0; i<links.length; i++) {
var link = links[i];
if (link.text == "printing link") {
link.click();
}
}
You can also run this in Chrome Dev Tools (open it by hitting Ctrl+Shift+I). Go in the Console tab and type your code directly or go in the Sources tab and add your script as a Snippet. It's good place to start in order to create an extension.
Hope this helps.
Related
I have a questing about knockout not rendering html attributes properly.
I have a span tag that gets populated with data using knockout JS.
<span id="s34" data-bind="html: $parent.Branch.TextComments"></span>
TextComments is dynamic and sometimes contain text only. Other times text and < a> tags. For example:
This is text example of TextComment. Access google at Goole link. Thank you!
When the page reders, the link reders correctly as a url but when I click it, it doesn't open a new tab, it redirects the page to google instead of opening a new tab which target="_blank" should accomplish.
Any ideas?
Thanks in advance!
I was curious if it really doesnt work.
I set up this minimal code snippet and everything works as expected in my local environment
var system = {
viewModel:function (data) {
var self = this;
self.texts = ko.observableArray([
"text 21321",
'text with target blank ',
'text <a href="https://google.com" > without target blank </a> ',
'text 789'
]);
}
}
var vm = new system.viewModel();
ko.applyBindings(vm);
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>
<div data-bind="foreach:texts">
<span data-bind="html:$data"></span> <br>
</div>
Test stack-snippet target-blank
So in this snippet the links do also not open correct for me, but maybe this is a snippet restriction. See the normal link i added with target="_blank" it also doesnt open in snippet. in my local environmet all the links with target="_blank" opens in a new tab while the other one does not
I'm having a problem on how will I target, here's the scenario, whenever I click the links Home, or food or resort etc. the contents of it should be outputted on the display below. What always happen is that when I click those links It always goes to a new tab. What I wanted is that it should display on the same page and on a given div. Please help me, I've been trying to search the internet but different results are coming up.
Here are my links
<div id = "panel">
<p>
<a href = "home.html" target = "display">
<font color ="white">Home</font
</a>
<a href = "resort.html" target = "display">
<font color ="white">Resort</font>
</a>
<a href = "hotel.html" target = "display">
<font color = "white">Hotel</font>
</a>
<a href = "food.html" target = "display">
<font color ="white">Food</font
</a>
<a href = "rates.html" target = "display">
<font color="white">Rates</font>
</a>
<a href="reservation.html"target="display
<font color="white">Reservation</font>
</a>
<a href = "contact.html" target = "display">
<font color = "white">ContactUs</font>
</a>
</p>
</div>
This is where the content should be put in
<div id="display">
<iframe name="display"></iframe>
</div>
If I understand the question--and I really don't--I think you're problem is pretty easy to fix. Just change this:
<name = "display">
To:
<iframe name="display">
I'm assuming you want to load those links inside an iframe, yes? Otherwise what you want to do will require javascript. But again, I'm not sure I understand.
There is no <name> tag in HTML, but there is a name attribute
Edit to explain iframes:
iframes load one web page B inside of webpage A, but the two are still separate pages. The "box" is probably the border of the iframe itself. The scrollbar appears when the content of webpage B is too large for the iframe to display everything at once. To get rid of the scrollbar, you can either make the iframe larger or make the content of webpage B smaller.
Making an iframe larger is no different than making any other element larger: just change it's CSS.
I have tried this. Use this code <JsFiddle Link> :
At first load the jQuery:at the top of the code
<script src="https://code.jquery.com/jquery-1.10.2.js"></script>
Then add this jQuery code at the bottom of the file. In this code you will just check when an anchor tag is clicked and then return false which will prevent the anchor tag click submission. As well as load function will load the desired file of the "href" attribute.
<script>
$("a").on("click", function(){
//alert($(this).attr("href"));
$( "#display" ).load( $(this).attr("href") );
return false;
});
</script>
NB: If you are running this in local server there is no problem. You also can load .php file in it. But if you are running it in Windows explorer or linux file system then open it in firebox.
yes crowhill is right. i think you want to have a single page website. then you have to write all the contents in a single html page with different divs for different contents which you want to display using the links and use the id of the divs in the href part of your tag (i.e. ).
i think this will clear your query.
https://www.freshdesignweb.com/free-one-page-wordpress-themes/
I have a page with multiple table rows. Each row contains several links. I'm trying to get some links specifically and, using jquery, open them up in new windows. Here's what the page code looks like:
<tr>
<td colspan="3" width="122" valign="top" height="100">
<font class="verds1">
<a href="esignup.php?eSessID=12871419"
title="Breakfast-650944"><font color="#4F4F4F"><b>Breakfast-650944</b></font></a>
<br><br style="line-height: 7px"></font>
<font class="verds1">
<a href="esignup.php?eSessID=12873457"
title="Lunch-654335"><font color="#FF0000"><b>Lunch-654335</b></font></a>
<br><br style="line-height: 7px"></font>
<font class="verds1" color="#000000"><b>f-</b></font>
<font class="verds1">
<a href="esignup.php?eSessID=1287141"
title="Dinner-651092"><font color="#4F4F4F"><b>Dinner-651092</b></font></a>
<br><br style="line-height: 7px"></font>
<font class="verds1">
<a href="esignup.php?eSessID=1282131"
title="Dinner-651222"><font color="#4F4F4F"><b>Dinner-651222</b></font></a>
<br><br style="line-height: 7px"></font>
</td>
<tr>
In the above example, I'm looking to target only the links where the title contains the word 'Dinner', since the number following it will be different. Here there are two that match this criteria, but a page might have 5 or 6. I'm guessing I will have to put them in an array.
My questions are:
How do I grab the urls from just the links with 'Dinner' in the title?
How do I open up a new tab/window for each of the urls?
I have a pretty good idea on how to target the specific links, and I've been testing it out on firebug.
var link = $('td').find('a').filter(':contains("Dinner")');
console.log(link);
However at this point it's only return to me the actual text of 'Dinner-651222', not the url. And it only returns one result, instead of multiple ones like the document contains.
Any help on this would be very much appreciated. Thanks!
You can try this:
// get all a tag who have Dinner
var link = $('td').find('a').filter(':contains("Dinner")');
// get length of a
var linkLength = link.length;
// parse one by one and get URl from a tag
for (var i = 0; i < linkLength; i++) {
// here is you all url
var linkURL = $(link[i]).attr('href');
// open each link in new window with custom settings
var winOption = 'toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=no,resizable=no,width=400,height=300';
window.open('http://localhost/mysite/' + linkURL, 'MyWindow', winOption);
// end
};
In regard to the second question. As far as I know, you can't open new tabs with Javascript. The best you can do is open a new window, that depending on the browser configuration it will open a new tab, or simply block it.
So, for opening a new window you can use:
<script>
window.open("http://www.google.com", "google");
</script>
If page has .pdf files linked then a message in <p> should be add just before end of the #mainontent div as a last paragraph <p>
for example this is default html?
<div id="maincontent">
<ul class="cheat_sheet_downloads">
<li>PDF, 316Kb</li>
<li>PNG, 77Kb</li>
</ul>
<div>
After detecting pdf
it should be like this
<div id="maincontent">
<ul class="cheat_sheet_downloads">
<li>PDF, 316Kb</li>
<li>PNG, 77Kb</li>
</ul>
<div>
<div id="ttip">
Most computers will open PDF documents automatically, but you may need to
download <a title="Link to Adobe website - opens in a new window"
href="http://www.adobe.com/products/acrobat/readstep2.html" target="_blank">
Adobe Reader</a>.
</div>
or as another div after #maincontent div. Is it possible with jquery?
Edit:
Page can have one or more PDF i want to add message at bottom. and i need IE 6 compatibility too
Edit 2 : I can't and don't want to use mouse over tooltip
var tip = "<p>Most computers will open PDF documents ";
tip += "automatically, but you may";
tip += "need to download <a title='Link to Adobe website-opens in a new window'";
tip +=" href='http://www.adobe.com/products/acrobat/readstep2.html'
target='_blank'>Adobe Reader</a>.</p>";
$(document).ready(function(){
//IF NUMBER OF PDF LINKS IS MORE THAN ZERO INSIDE DIV WITH ID maincontent
//THEN THIS WILL PUT TIP PARAGRAPH AS LAST CHILD OF DIV
if($("div#maincontent a[href*='/pdf']").length>0){
$("div#maincontent").children(":last-child").after(tip);
}
});
check it here
You can iterate through all the anchor tags and find the extension of this using jQuery.
But I don't think this will be enough for you. Some sites streams the files when a request is made to the server. You won't be able to determine what the server will download when such a request is made.
For example when I click on a button a request is made to the server and the server processes the request in the following manner.
Response.ContentType = "application/pdf";
Response.AppendHeader("Content-Disposition","attachment; filename=test.pdf");
Response.TransmitFile("yourfilepath);
Response.Flush();
This will force the browser to open a dialog box to either save or open the document.
I'm trying to figure out just how a particular function works on a Facebook page, and being no friend of JS syntax, am having trouble. Here's the question mark bit:
<a href="#" clicktoshowdialog="my_dialog" onclick="
(new Image()).src = '/ajax/ct.php?app_id=4949752878&action_type=3&post_form_id=3b933f46f9c4c44981e51b90c754bfce&position=2&' + Math.random();
FBML.clickToShowDialog("app4949752878_my_dialog");
return false;">
<img src="linktopicture" title="Are your friends fans?" width="190" height="230" />
</a>
<div style="display:none">
<div id="app4949752878_my_dialog" fbcontext="aa3fcff8e653">
<div class="app_content_4949752878" style="padding:10px">
<div with hidden then exposed content...
The functionality of this is an image that, when clicked, pops out the previously hidden div. I know that the app###### is prepended to all JS used in Facebook to limit its scope. I'm confused by the anchor parameter of
clicktoshowdialog="mydialog"
What is that identifying, and how is it targeting the div that's exposed when the image is clicked? Thanks for any clarification, and let me know if I can post any more sample code.
According to the wiki it's just for opening the dialog (which is defined at the bottom). Facebook generates the JS to open the dialog. The attribute got post-processed and the JS code (that you see in the onclick= attribute) was generated on it's basis.