Random banner links: How to open in new tab/window

I've added a random banner to a site I'm experimenting with, and I've got it to randomly load the images. The links are all set and working, but they open in the same window or tab. Is there a way to tell it to open the linked site in a new window or tab?
Here's the script:
<script language="JavaScript">
<!--
function random_imglink(){
  var myimages=new Array()
  //specify random images below.
  myimages[1]="img/banner-1.jpg"
  myimages[2]="img/banner-2.jpg"
  myimages[3]="img/banner-3.jpg"
  myimages[4]="img/banner-4.jpg"
  myimages[5]="img/banner-5.jpg"
  //specify corresponding links below
  var imagelinks=new Array()
  imagelinks[1]="http://www.website.com"
  imagelinks[2]="http://www.website.com"
  imagelinks[3]="http://www.website.com"
  imagelinks[4]="http://www.website.com"
  imagelinks[5]="http://www.website.com"
  var ry=Math.floor(Math.random()*myimages.length)
  if (ry==0)
     ry=1
     document.write('<a href='+'"'+imagelinks[ry]+'"'+'><img src="'+myimages[ry]+'" border=none></a>')
  random_imglink()
//-->
</script>

I think part of your problem might lie in the way you are trying to use your quotation marks.  It appears you are trying to have the single quotes do what double quotes should be doing.
document.write("<a href='"+imagelinks[ry]+"' target='_blank'><img src='"+myimages[ry]+"' border='none'></a>
If you want to have doublequotes appear in code as doublequote characters you can try slashing them to have them read literally... \"
document.write("<a href=\""+imagelinks[ry]+"\" target=\"_blank\"><img src=\""+myimages[ry]+"\" border=\"none\"></a>

Similar Messages

  • Safari 6.0 crash when right clicking a link and choosing open in new tab

    Hi all,  just a general question.  I admit i did not search the forums yet.  Hopefully this little annoyance can be resolved.
    When using safari on say CNN.COM i'll right click on a link and choose Open in new tab.  safari randomly disappears.  no crash warnings,  just gone.  I can open it right up and be fine sometimes all day.   This has happened to me about 5x since ML was released (i wiped my laptop the day it came out)
    This has happened on a couple of different website at different times of the day.  only safari was running. No other apple apps have this issue.
    I have a MacBook Pro from earily '08 type 4,1
    i have only apple software on this machine
    i do have adobe flash installed v11.3 updated today.
    i do have lastpass enabled
    i do have ad-block disabled
    While i'm waiting for help from you guys i'll disable all addon's and try to remove adobe to see if that is the issue.  Is there any other steps i can try like delete .plist file or maybe even trying a new user profile.  I am a IT professional and am not afraid to get my hands dirty trying to get this resovlved.
    Thanks in advance.
    P.S. i'll search the forums too and if i see a similar post i'll remove this one.
    Bill Siegfried.

    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Console in the page that opens.
    Step 1
    Enter the name of the crashed application or process in the Filter text field. Post the messages from the time of the last crash, if any — the text, please, not a screenshot.
    Important: Some private information, such as your name, may appear in the log. Edit it out by search-and-replace in a text editor before posting.
    Step 2
    Still in the Console window, look under User Diagnostic Reports for crash reports related to the process. The report name starts with the name of the crashed process, and ends with ".crash". Select the most recent report and post the contents — again, the text, not a screenshot. In the interest of privacy, I suggest that, before posting, you edit out the “Anonymous UUID,” a long string of letters, numbers, and dashes in the header of the report, if it’s present (it may not be.) Please don’t post shutdownStall, spin, or hang logs — they're very long and not helpful.

  • I open facebook or other site. right click link/photo to open in new tab quickly. Then all tab connection will be connection to website, all page stop loading. Have to close firefox and reopen then only site will load.

    I open facebook or other site. right click link/photo to open in new tab quickly. Then all tab connection will be connection to website, all page stop loading. Have to close firefox and reopen then only site will load.

    You can override how links are opened via the browser.link.open_newwindow.override pref.
    *http://kb.mozillazine.org/browser.link.open_newwindow
    *1: current tab; 2:new window; 3:new tab;
    Use this for links opened via JavaScript.
    *http://kb.mozillazine.org/browser.link.open_newwindow.restriction
    See also:
    *http://kb.mozillazine.org/Prevent_websites_from_disabling_new_window_features

  • Is there a way to 'Force all Links to be opened in New Tabs ' like Maxthon browser?

    Is there a way to get Firefox to 'Force all Links to be opened in New Tabs, like Maxthon browser does ? I really like this Maxthon feature but hate Maxthon as it has always has and continues to lock up all the time (what a pain!!)
    Hoping Firefox can do this. By the way I know if you right click a link and ask for it to open in a new tab it will. I want it to be automatic.
    Thank you

    Question already asked and answered.
    I gave an AppleScript and an other helper described a scheme relying upon standard features.
    Yvan KOENIG (VALLAURIS, France) jeudi 21 juillet 2011 23:08:28
    iMac 21”5, i7, 2.8 GHz, 4 Gbytes, 1 Tbytes, mac OS X 10.6.8
    Please :
    Search for questions similar to your own
    before submitting them to the community
    To be the AW6 successor, iWork MUST integrate a TRUE DB, not a list organizer !

  • Click web link doesn't open a new tab

    Before whenever I click on a web link, FF always open a new tab for me. I just recent rebuilt my PC and upgraded FF to 13.0. Now no matter what I change in Options, it only opens the link on my current web page. I know I can do Right-Click but I am just used to this. I found others were having the same issue but they were on much lower version of FF and I don't have any mentioned Add-on installed.

    I don't think there is a setting to open all links in a new tab. You can set all links that would normally open in a new window to open in a new tab instead. And like you said you can right-click and select open in a new tab. Also if you click a link to another website from an App Tab it will open in a new tab.
    I did find [https://addons.mozilla.org/en-US/firefox/search/?q=open%2Blinks%2Bin%2Ba%2Bnew%2Btab&platform=windows&appver=13.0&page= these add-ons] that might help.

  • I can't open a new tab unless I right click a link and hit "open in new tab"?

    I can't open a new tab unless I right click a link and hit "open in new tab."
    I click ctrl+t, click the new tab button, right click the tab bar and hit "new tab", and even click "File" and hit "New Tab", but it still won't open a tab!
    This has been going on for a week!
    I know it may not seem like too much of a problem since I can still open a tab, but it's terribly inconvenient that I can only open one by clicking a link.

    The Ask Toolbar is causing that in the Firefox 3.6.13+ versions. Uninstall that extension.
    There are a couple of places to check for the Ask toolbar:
    * Check the Windows Control panel for the Ask Toolbar - http://about.ask.com/apn/toolbar/docs/default/faq/en/ff/index.html#na4
    * Also check your list of extensions, you may be able to uninstall it from there - https://support.mozilla.com/kb/Uninstalling+add-ons

  • Why does right clinking on link and selecting open in new tab does not work?

    Why does right clinking on link and selecting open in new tab does not work?
    It opens up a blank page. The only way to make the link work is to click on the navigation bar in the new tab and press enter to reload the link.

    Do you have that problem when running in the Firefox SafeMode?<br/> ''A troubleshooting mode.''<br />
    1.You can open the Firefox 4.0 SafeMode by holding the '''Shft''' key when you use the Firefox desktop or Start menu shortcut. <br />
    2. Or use the Help menu item, click on '''Restart with Add-ons Disabled...''' while Firefox is running. <br />
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before using the Firefox shortcut to open it again.''
    If not, see this: <br />
    http://support.mozilla.com/en-US/kb/troubleshooting+extensions+and+themes

  • Can't open new tab by going to file/new tab (or CTRL+T or clicking on the new tab field). Only way is to right click on a link and choose open in new tab.

    Can't open new tab by going to file/new tab (or CTRL+T or clicking on the new tab field). Only way is to right click on a link and choose open in new tab.

    Hello,
    '''Try Firefox Safe Mode''' to see if the problem goes away. Safe Mode is a troubleshooting mode, which disables most add-ons.
    ''(If you're not using it, switch to the Default theme.)''
    * You can open Firefox 4.0+ in Safe Mode by holding the '''Shift''' key when you open the Firefox desktop or Start menu shortcut.
    * Or open the Help menu and click on the '''Restart with Add-ons Disabled...''' menu item while Firefox is running.
    ''Once you get the pop-up, just select "'Start in Safe Mode"''
    '''''If the issue is not present in Firefox Safe Mode''''', your problem is probably caused by an extension, and you need to figure out which one. Please follow the [[Troubleshooting extensions and themes]] article for that.
    ''To exit the Firefox Safe Mode, just close Firefox and wait a few seconds before opening Firefox for normal use again.''
    ''When you figure out what's causing your issues, please let us know. It might help other users who have the same problem.''
    Thank you.

  • Tip Message with hyperlink to open in new tab/window

    Hi Guys,
    I have created a FND Message which has the following content:
    some text <a href="https://www.google.co.uk"target="_blank">Click Here</a> some more text
    This is referenced in a custom OAF page as a Tip Message (OATipBean), the text and hyperlink render with no issues, however the hyperlink does not open in a new tab/window (it opens in the current tab) - when you view the source of the page the '...target="blank"...' is not there:
    ... <a href="https://www.google.co.uk">Click Here</a> ...
    Is there a way of getting hyperlinks in Messages to open in new tabs/windows?
    Regards
    Carl
    Message was edited by: CarlHammond

    I think part of your problem might lie in the way you are trying to use your quotation marks.  It appears you are trying to have the single quotes do what double quotes should be doing.
    document.write("<a href='"+imagelinks[ry]+"' target='_blank'><img src='"+myimages[ry]+"' border='none'></a>
    If you want to have doublequotes appear in code as doublequote characters you can try slashing them to have them read literally... \"
    document.write("<a href=\""+imagelinks[ry]+"\" target=\"_blank\"><img src=\""+myimages[ry]+"\" border=\"none\"></a>

  • When I right-click a link, and choose "Open in new tab", it opens in a new window instead. How can I fix this?

    So I have Firefox open, and I've tried to open tabs by right clicking and choosing "open in new tabs", but it opens in a new window instead. And yes, there are no problems with being able to open new tabs by pressing the ctrl t.

    The Ask Toolbar is causing that in the Firefox 3.6.13+ versions. Uninstall that extension.
    There are a couple of places to check for the Ask toolbar:
    * Check the Windows Control panel for the Ask Toolbar - http://about.ask.com/apn/toolbar/docs/default/faq/en/ff/index.html#na4
    * Also check your list of extensions, you may be able to uninstall it from there - https://support.mozilla.com/kb/Uninstalling+add-ons

  • Some links like youtube open in new tab but never have before, how do I fix this?

    All of a sudden, when I go to youtube or really anything. It opens it in a new tab when it never did before. It would only open in new tab when I told it to or when I clicked on a url. I really don't know a lot about this so if somebody could help me that would be great.

    Did you check the settings?
    *Tools > Options > Tabs: [X] "Open new windows in a new tab instead"
    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem.
    *Switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance
    *Do NOT click the Reset button on the Safe Mode start window
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • How to open a new tab after current browsing session.

    I used to use new tab king, and when I opened a new tab, it would always open the new tab to the very right of my session, out of the way and not somewhere randomly in the middle. However, I wanted my restored windows to open where I had closed them in my session. I have since changed to use new tab plus instead, and it worked that same way before, but since I updated to firefox 26, it seems to have reset that option (as well as others), it opens in the middle of the session now instead of the end.

    I'm not sure what you mean by the middle of the ''session''.
    Do you mean the middle of the tab bar in the current window? There is a setting for whether to open a link in a new tab adjacent to the page where you clicked the link or always at the end of the tab bar. If that's what you mean, here's how you can switch it:
    (1) In a new tab, type or paste '''about:config''' in the address bar and press Enter. Click the button promising to be careful.
    (2) In the search box above the list, type or paste '''tabs''' and pause while the list is filtered
    (3) Double-click the '''browser.tabs.insertRelatedAfterCurrent''' preference to switch it from true to false.
    But I'm not sure that's what you meant... also, extensions may override Firefox's built-in behaviors with their own tab settings.

  • Clicking link in mail opens a new tab, not a new window

    When clicking on a link in AppleMail, after a recent update, opens a tab in a random window or perhaps the top window in Safari.  Until this update, clicking on the link used to open a new window.  This is driving me nuts.  I am getting links from mail opening in a new tab in Safari windows I reserve for specific topics, or uses.  I do not want unrelated mail links opening and interfering with work in these existing browser windows.  Also, when I see the link from mail is not wanted, I too often close the window like I usually do, but now inadvertently close a Safari window with multiple tabs of important information, that I have trouble recreating.  Where did this come from!?  How do I change it so a new window opens? 

    I was having the same problem and finally figured out how to change this bahavior.  Go to Safari preferences under the 'Tabs' settings.  Make sure the field "Open pages in tabs instead of windows" is set to NEVER.  That should do the trick.

  • Pdf links will not open in new browser window

    I have created a pdf document in Acrobat 9 Pro that is password protected. You must enter the password to open it. In this document there are perhaps 15 links to other pdf documents. I set up each of the links to open in a new window. The links work as expected in Acrobat, each opening in a new window, however, when I posted the documents to the web, the links open in the same window as the original document. This would not be a big issue if the original document were not password protected, but each time the user clicks on a link, it takes him out of the original document. To get back to the original document requires re-entering the password. This is a major irritation with so many links.
    I know that you can set Acrobat to display the documents in its own window rather than in the browser, but my users don't know that. Control clicking on a pdf link does not open it in a new window as it would with an HTML link. Is there a simple fix to this problem that does not involve user intervention?

    Well, I came up with a solution, thanks to Ted Padova who offers a simple JavaScript solution on his blog at http://www.acrobatusers.com/blogs/tedpadova/opening-pdfs-new-browser-windows.
    The solution is clearly laid out even for beginners, if you know how to create a link or button.
    It seems to me that a prime objective of Adobe in developing Acrobat would be to have it behave the same way in free-standing mode and as a plug-in. In this case it does not, and obviously, it has not for the last forty-eleven years that Acrobat has been on the market. Maybe some day they will get around to a fix for this obvious problem. In the meantime, read Ted's blog and be happy we have guys like him who can solve these problems.

  • Links list to open in new tab

    I have created a links list and added that webpart to a page in office 365 for sharepoint. When the user clicks on a links it needs to be opened in new tab how to impletement.
    I tried with javascript content editor webpart but it is removing  the  scroll bar of the page.
    Please let me know. many thanks in advance
    Regards,
    Chaitanya

    Hi Chaitanya,
    May check this article to find the similar code in Links list web part with SharePoint Designer, add the attribute target="_blank" within the code, then check results.
    http://365.webbrewers.com/blog/Lists/Posts/Post.aspx?ID=9
    Thanks
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

Maybe you are looking for

  • Can't get my first Function to work!

    Hi everyone, I have been trying to make a function, but it won't compile without errors. I already checked the forum and other sites for an answer, but I can't seem to find one. So here's my function (I'm taking an integer value as an input and retur

  • I add a "Submit" button, but it doesn't work?

    I added a Submit button to a form, but it does not show up once the form is distributed. It this one of the many issues with the "Submit: button?

  • Load SMP.swf in other .swf and pass parameters to it

    Hello, I am able to load the StrobeMediaPlayback.swf within my main .swf application, but I have no idea how to mimic the flashvars behaviour : how can I provide it with the source of the video wanted, etc ? Thx

  • OOBE phase not processing

    I am having some trouble with my OOBE Phase pass. It seems that only part of it is being processed. I am always prompted to create a user account but all other parts (network type, time/date, EULA, ect) are all handled by the answer file-but the user

  • Can't copy and paste using mouse

    Hello all. It seems that after the installation of patch # 19 for Unix AIX the feature of copy and paste by using the middle button of the mouse doesn't work anymore. Does anyone confirm this behavior? If so, is there any work around to solve this is