Create an HTML link to a file in another port? [duplicate] - html

This question already has answers here:
Relative URL to a different port number in a hyperlink?
(12 answers)
Closed 9 years ago.
The tag below ceates a link to a page without having to provide the full URL:
link
So if you click it from example.com/, you'll go to example.com/foo.html. Is there a way to create a link that'll go to example.com:port/foo.html instead?

See here -> https://stackoverflow.com/a/6016361/773263
// delegate event for performance,
// and save attaching a million events to each anchor
document.addEventListener('click', function(event) {
var target = event.target;
if (target.tagName.toLowerCase() == 'a')
{
var port = target.getAttribute('href')
.match(/^:(\d+)$/);
if (port)
{
target.port = port[1];
}
}
}, false);
Seems to be the best way to do it. I don't think a purely HTML solution is possible.

Related

How does text url parameter work? [duplicate]

This question already has answers here:
Backbone router with multiple parameters
(2 answers)
Closed 6 years ago.
PLEASE INVEST SOME TIME READING THE QUESTION COMPLETELY BEFORE MARKING OR ANSWERING
I want to display text from data in url and access it using the same. Eg.
http://stackoverflow.com/questions/24888693/how-does-out-parameter-work
Notice how this page is accessed using the param how-does-out-parameter-work
Currently i am using requireJs with backboneJs in my web app. So, in my router i am routing like
siteTitle = 'Boiler Plate';
define([
'jquery',
'underscore',
'backbone',
'handlebars',
'jcookie',
'views/home',
'views/404'
], function ($, _, Backbone, Handlebars, jcookie, HomePage, FoFPage) {
var AppRouter = Backbone.Router.extend({
routes: {
':*':'home',
'home' : 'home',
'home/:a' : 'home',
'*whatever' : '404'
},
home: function (a) {
document.title = siteTitle + ' - Home';
homePage = new HomePage({route: a});
homePage.render();
},
404: function(){
document.title = siteTitle + ' - 404';
fofPage = new FoFPage;
fofPage.render();
}
});
var initialize = function () {
var app_router = new AppRouter;
Backbone.history.start();
};
return {
initialize: initialize,
AppRouter: AppRouter
}
});
Notice that i am getting the passed parameter a and them loading the page accordingly. Currently i am setting that parameter a as a number that is my post ID and using it accordingly. Bu if i want to pass a portion of my post's heading and access it how can i do that?
I can think of one way is selecting substring from mysql data base and based on url input but it wont help as if the parameter is how-does-out-parameter-work i can never parse it as How does 'out' (parameter) work? which is actual text in database. What am i missing?
UPDATE
the ignoring the post param is only applicable in stackvoerflow not on this site
https://www.theguardian.com/us-news/2016/nov/10/hate-crime-spike-us-donald-trump-president is using something else. What am i missing?
If you're attempting to follow the same process as Stackoverflow, they appear to use an Id for each question. I can only speculate what the title parameter is used for.
http://stackoverflow.com/questions/24888693/how-does-out-parameter-work
Equates to the following:
{domain}/{questions}/{questionId}/{title-string}
You can see that the title-string is an option parameter as the following will still route you to the correct question
http://stackoverflow.com/questions/24888693
The additional parameter is likely to stop duplicate Ids causing an issue in the database if the question Id counter has to be reset.
Maybe you can clarify why you need to search for a hypenated string in the databse?

Checkbox and Radio buttons behaviour [duplicate]

This question already has answers here:
How to uncheck checked radio button [duplicate]
(5 answers)
Closed 6 years ago.
I am using a set of checkboxes to have some drop-down menus by switching their display:none; to display:block when box or radio is checked.
This is the checkbox version : https://jsfiddle.net/hw207q2L/
and this is the radio version : https://jsfiddle.net/3xzuw47x/
I'd like to combine both so that when opening a new part it closes the other ones (radio behaviour) ; while at the same time being able to close the part I opened by clicking it again (checkbox behaviour).
Any ideas that wouldn't involve javascript ? I'd like to restrain from using js, but if it's not possible tell me.
It requires functionality that prevents default behavior, so it's unlikely to make it happen without the using of additional framework or javascript.
This not exactly a duplicate, but please check How to uncheck checked radio button [duplicate].
Just use this javascript in your second version of code:
var allRadios = document.getElementsByName('titles');
var booRadio;
var x = 0;
for(x = 0; x < allRadios.length; x++){
allRadios[x].onclick = function() {
if(booRadio == this){
this.checked = false;
booRadio = null;
}else{
booRadio = this;
}
};
}

How do I limit the number of file upload in html? [duplicate]

This question already has answers here:
Count and limit the number of files uploaded (HTML file input)
(4 answers)
Closed 5 years ago.
I want to limit user to select up to 6 files in the input tag. Currently, my input tag is like this:
<input type="file" name="question_pic" id="id_question_pic" multiple/>
I would like to limit user to select up to 6 files. I can return an error on the server side but I want client side to change it first.
Is there a way to do that?
Thanks.
You can use a jQuery function like this:
$('.fileinput').change(function(){
if(this.files.length>10)
alert('Too many files')
});
// Prevent submission if limit is exceeded.
$('form').submit(function(){
if(this.files.length>10)
return false;
});
You can use Jquery or Javascript for that like this:
<input type="file" name="question_pic" id="id_question_pic" max-uploads = 6/>
Then in Jquery You can do this like this
Var number_of_uploads;
$("#id_question_pic").change(function() {
if(number_of_uploads > $(this).attr(max-uploads))
{
alert('Your Message');
}
else
{
number_of_uploads = number_of_uploads + 1;
}
});
You can also do this on your form submission in which you are uploading the file. But if you are using Ajax upload this is fine I think.

Final window close event listener in chrome browser [duplicate]

This question already has answers here:
Event onBrowserClose for Google Chrome Extension?
(5 answers)
Closed 7 years ago.
Multiple separate windows can be opened in chrome,
chrome.windows.onRemoved.addListener(function(windowId){
// action
});
Above code responds for any chrome window close event.
How to detect the last window close event or ultimate close event.
if not, is there method available to check any chrome window left active before handling close event.
Thanks !
onRemoved:
chrome.windows.onRemoved.addListener(function callback)
Fired when a window is removed (closed).
getAll:
chrome.windows.getAll(object getInfo, function callback)
Gets all windows.
chrome.windows.onRemoved.addListener(function () {
chrome.windows.getAll(function (windows) {
if (windows.length <= 0) {
// Write code here
}
});
});
var openWindowCount = 0;
chrome.windows.onCreated.addListener(function(Window window) {
++openWindowCount;
});
chrome.windows.onRemoved.addListener(function(windowId) {
if (--openWindowCount == 0) {
// this is the last window.
}
);
Not tested.

Uploading picture in Div using sencha touch [duplicate]

This question already has answers here:
phoneGap camera and sencha touch view
(3 answers)
Closed 9 years ago.
I am working on sencha from last 20 days or so i have learnt a lot , I have got access to device camera and capturing photo using that camera but the problem is that i want to show that captured image in a Div in my page using a button .. Couldn;t got the solution Please help if anyone knows .. Take a look at this ..
{
xtype:'button',
text:'Tap',
docked:'top',
handler:function(){
navigator.camera.getPicture(onSuccess, onFail, { quality: 50,
destinationType: Camera.DestinationType.FILE_URI });
function onSuccess(imageURI) {
var image = document.getElementById('myImage');
image.src = imageURI;
}
function onFail(message) {
Ext.Msg.alert('Failed because: ' + message);
} }
},
{
xtype:'container',
html:'<div style="border:solid;border-color:red">Hello</div>',
id:'picture',
},
{
xtype:'container',
html:'<div style="border:solid; border-color=green">Hellow</div>',
items:[
{
xtype:'button',
text:'Get',
}
]
},
what i have to do now ??
You need to do something with the element that has ID 'myImages'. In the onSuccess function you are setting the src of that element accordingly, but where is the element actually used? You should add it to one of the containers, either in the initial definition or when onSuccess is called. If you want to wait until the button with text 'Get' is pressed then either have that button's handler append the myImages element, or hide/show it.