HTML hyperlink is not operning in a new tab - hyperlink

echo "<td align = 'center'><a href='edit/edit_rrdalert.php?id=".$alertid .
"&title=".$inst_title."&cat=".$categories["$cat"]."'target='_blank'>edit </a>";
I want to open the link in a new tab as edit/edit_rrdalert.php?id.

It shouldn't be your call to decide whether the link should open in a new tab or a new window, since ultimately this choice should be done by the settings of the user's browser. Some people like tabs, some other like new windows.
Using _blank will tell the browser to use a new tab/window, depending on the user's browser configuration, and also depending on how they click on the link (middle click, ctrl+click, normal click).
but if you wish to do it set the target attribute of your element to "_tab"
EDIT: It works, however W3Schools says there is no such target attribute: http://www.w3schools.com/tags/att_a_target.asp

Related

Rich Text Editor in Rails: Show the target tab for links in the link dialog window

I am using Activeadmin with Rich Editor.
When I add a link to my text within the window of the editor i cannot set how the link is being opened - wether it is in a new tab or a new window ..
I understand that the Rich editor derives from CKEditor with certain features being disabled and that these features can be reenabled.
Also I know, that this particular feature is set in the config by the line
config.linkShowTargetTab = true
I am just not sure on where to put it exactly so that it is enabled globally.
Thanks for any advice on this.
In the gem source (lib/rich.rb) you can see the default buttons defined in ##editor[:toolbar]:
##editor = {
...
:removeDialogTabs => 'link:advanced;link:target',
...
}
If I delete ";link:target" the Tab is shown in my app.

How do I open the previous active tab when returning from a new html page

How do I return back to the previous active tab if I am moving back from another html page?
I am having 5 tabs and within content of each tab there are links to another set of html pages. For example I am having a page called 'school.html' and it has 5 tabs. In tab 2 content (it shows individual student details) I am having a link to "Add new student" to a new page named addNewStudent.html.
After adding a new student in addNewStudent.html, I need to automatically comeback to original page with tabs (window.location = 'school.html'). So how to make tab 2 active showing the tab 2 content (student details).
This can be done in two ways depends upon your usage..
1)if you use browser back in addNewStudent.html to go to school.html.Better to use cookie concept.
For ex: when going to addNewStudent.html from school.html setcookie("tabchange","tab2")
when coming back from addNewStudent.html to school.html(onload of school.html check whether the cookie exist or not,if exists depends upon cookie enable your tab);
2) if you use any button or link in addNewStudent.html to go to school.html.Better to use queryparams.
for ex: pass tabchange queryparam for school.html to addNewStudent.html?tabchange=tab1
get that queryparam from addNewStudent.html and assign to link or button your as href="/school.html?tabchange=tab1"
after clicking that button onload of school.html get the queryparam and enable the tab..

JQuery Mobile & passing variables in links via the querystring - but the querystring doesn't refresh

I am doing a PhoneGap app with JQuery Mobile and I have two pages, one that has a dynamic list of pages and one that has a form to either edit or create a page. These are in a single html file.
Tapping on a list item passes ?action=edit and tapping the "Add" button I have, passes ?action=add querystrings.
Here is a jsfiddle to visualize the pages
NOTE: The example doesn't act quite the same as the live code.
I am running my app on an Android phone and if I do these actions, the correct querysting is observed in the alert box: -
Click the add button on list page
Click back on the form page
Click the an edit list item link on list page
However, if I do it the other why around (click edit first, then the add button) clicking the add button never shows the add querystring in the alert box
(the jsfiddle example always locks the first clicked link's querystring, which is even worse than the live code!)
The problem here is that you're using a multiple template to do this. If you were using this as separate pages, this would work as normal. As a multiple app, the best way to handle this would be to make a link trigger the setting of some global variable that keeps track of the current state of the app.
Make the edit links like this
Page 15
Then make the script something like this:
var editingId = 0
function editPage(id){
editingId = id;
$.mobile.changePage("#editingPage");
});
$("div#editingPage").live("pageshow", function(){
loadDataForPage(editingId);
});

How can one change the url for a jquery ui tab added via 'add' and 'tabTemplate' functionality?

I might be making this more difficult than I need to but I am in some need of assistance. I have some jquery ui tabs which are added via the add functionality. these tabs are via ajax.
I have a tabTemplate set as follows on the initial addition of the tabs.
tabTemplate: "<li><a href='#{href}'>#{label},/a><li>"
And the add tab functionality is done via
$tabs.tabs('add', 'http://thanksforyourhelp/greatly/appreciated/, some_title_var)
If a form is submitted on that tab, data is written to the database. The response gives an ID of the row added to the database.
Next time that specific tab is visited the link should actually be 'http://thanksforyourhelp/greatly/appreciated/ID' where the ID is now known since the response from the form (ajax here as well) sent it back. This will pre-populate the forms on the page based off the data in the database for "ID."
I've looked at the example here, but my href is an id for the tab in question (and not a url). Where is the actual url stored?
The tab looks like this.
new
I have tried changing the href on that, but upon clicking the tab the content is loaded without ajax instead of within the tab as desired. What might I be doing wrong here? Thanks for your help.
Edit: removed edits with references of no longer existent urls.
I haven't worked with AJAX-powered tabs too much, but I think you want the url method:
$("#tabs").tabs("url", index, url)
Change the url from which an Ajax
(remote) tab will be loaded. The
specified URL will be used for
subsequent loads. Note that you can
not only change the URL for an
existing remote tab with this method,
but also turn an in-page tab into a
remote tab.
Above answer will not work in JQuery 1.9+ as describer here. To work with jquery ui tabs 1.9+ you have to do something like this
var tabs = $("#tabs");
var tab = $(tabs.data('uiTabs').tabs[TAB_INDEX]);
tab.find('.ui-tabs-anchor').attr('href', "NEW_URL");
// If cached initially. Remove cache then
tab.data( "loaded", false);
tabs.tabs( "option", "active", TAB_INDEX);
tabs.tabs("load", TAB_INDEX);
This will change the URL of tab at particular index and load that tab.

smartgwt browser history

is there a way in smartgwt to go back in history?
E.g. I have an page with a button which does a Ajax page change of the current page to another. And on this new page there should be a button to return back to the previous page?
Can this be done with smartGWT? or do I have to make a new Ajax call to switch back to the previous page?
The functionality you want is provided by History class. Need to declare in web.xml and then use History.fireItem("SomeURL"), this will appear in app url as the string after # in URL is History ID ( something like http://google.com#SomeURL), you can use arbitrary IDs.
Use History.registerCallback() to register a function that opens requested History ID (eg. tab name/ID) on URL change (History's ValueChange function) and use History.addHistoryEntry() to update the page URL when other tab is selected.
If you implement this History class then you can use the browser's forward and back icon for the same purpose.

Resources